Commit 8b7f0358 authored by DonLakeFlyer's avatar DonLakeFlyer

Fix crash from bad toolbox reference during shutdown

parent c4478240
......@@ -92,25 +92,23 @@ void AppLogModel::threadsafeLog(const QString message)
insertRows(line, 1);
setData(index(line), message, Qt::DisplayRole);
if (qgcApp()->logOutput()) {
if (_logFile.fileName().isEmpty()) {
QGCToolbox* toolbox = qgcApp()->toolbox();
// Be careful of toolbox not being open yet
if (toolbox) {
QString saveDirPath = qgcApp()->toolbox()->settingsManager()->appSettings()->crashSavePath();
QDir saveDir(saveDirPath);
QString saveFilePath = saveDir.absoluteFilePath(QStringLiteral("QGCConsole.log"));
_logFile.setFileName(saveFilePath);
if (!_logFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
qgcApp()->showMessage(tr("Open console log output file failed %1 : %2").arg(_logFile.fileName()).arg(_logFile.errorString()));
}
if (_logFile.fileName().isEmpty() && qgcApp()->logOutput()) {
QGCToolbox* toolbox = qgcApp()->toolbox();
// Be careful of toolbox not being open yet
if (toolbox) {
QString saveDirPath = qgcApp()->toolbox()->settingsManager()->appSettings()->crashSavePath();
QDir saveDir(saveDirPath);
QString saveFilePath = saveDir.absoluteFilePath(QStringLiteral("QGCConsole.log"));
_logFile.setFileName(saveFilePath);
if (!_logFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
qgcApp()->showMessage(tr("Open console log output file failed %1 : %2").arg(_logFile.fileName()).arg(_logFile.errorString()));
}
}
}
if (_logFile.isOpen()) {
QTextStream out(&_logFile);
out << message << "\n";
}
if (_logFile.isOpen()) {
QTextStream out(&_logFile);
out << message << "\n";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment