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) ...@@ -92,25 +92,23 @@ void AppLogModel::threadsafeLog(const QString message)
insertRows(line, 1); insertRows(line, 1);
setData(index(line), message, Qt::DisplayRole); setData(index(line), message, Qt::DisplayRole);
if (qgcApp()->logOutput()) { if (_logFile.fileName().isEmpty() && qgcApp()->logOutput()) {
if (_logFile.fileName().isEmpty()) { QGCToolbox* toolbox = qgcApp()->toolbox();
QGCToolbox* toolbox = qgcApp()->toolbox(); // Be careful of toolbox not being open yet
// Be careful of toolbox not being open yet if (toolbox) {
if (toolbox) { QString saveDirPath = qgcApp()->toolbox()->settingsManager()->appSettings()->crashSavePath();
QString saveDirPath = qgcApp()->toolbox()->settingsManager()->appSettings()->crashSavePath(); QDir saveDir(saveDirPath);
QDir saveDir(saveDirPath); QString saveFilePath = saveDir.absoluteFilePath(QStringLiteral("QGCConsole.log"));
QString saveFilePath = saveDir.absoluteFilePath(QStringLiteral("QGCConsole.log"));
_logFile.setFileName(saveFilePath);
_logFile.setFileName(saveFilePath); if (!_logFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
if (!_logFile.open(QIODevice::WriteOnly | QIODevice::Text)) { qgcApp()->showMessage(tr("Open console log output file failed %1 : %2").arg(_logFile.fileName()).arg(_logFile.errorString()));
qgcApp()->showMessage(tr("Open console log output file failed %1 : %2").arg(_logFile.fileName()).arg(_logFile.errorString()));
}
} }
} }
}
if (_logFile.isOpen()) { if (_logFile.isOpen()) {
QTextStream out(&_logFile); QTextStream out(&_logFile);
out << message << "\n"; 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