Fix crash on logger; make log window modalless (#2659)

This commit is contained in:
ctrlaltca 2017-04-26 21:05:24 +02:00 committed by Zach H
parent 9dd3a04a08
commit ce77d51a8f
6 changed files with 39 additions and 18 deletions

View file

@ -48,21 +48,24 @@ void Logger::closeLogfileSession()
}
void Logger::log(QtMsgType /* type */, const QMessageLogContext & /* ctx */, const QString &message)
void Logger::log(QtMsgType /* type */, const QMessageLogContext & /* ctx */, const QString message)
{
QMetaObject::invokeMethod(this, "internalLog", Qt::QueuedConnection,
Q_ARG(const QString &, message)
);
}
void Logger::internalLog(const QString message)
{
QMutexLocker locker(&mutex);
logBuffer.append(message);
if (logBuffer.size() > LOGGER_MAX_ENTRIES)
logBuffer.clear();
logBuffer.removeFirst();
if (message.size() > 0) {
emit logEntryAdded(message);
std::cerr << message.toStdString() << std::endl; // Print to stdout
emit logEntryAdded(message);
std::cerr << message.toStdString() << std::endl; // Print to stdout
if (logToFileEnabled)
fileStream << message << endl; // Print to fileStream
}
}
if (logToFileEnabled)
fileStream << message << endl; // Print to fileStream
}