forked from qt-creator/qt-creator
CMakePM: Fix crash (potential) on CMakeParser::flush
Use the Task copy for the inversal of the call stack.
Amends edf4280bd9
Fixes: QTCREATORBUG-29965
Change-Id: I6119e03c75ff5a7d44f86e91cc93e6417fea1689
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -202,22 +202,25 @@ void CMakeParser::flush()
|
|||||||
if (m_lastTask.isNull())
|
if (m_lastTask.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_lastTask.summary.isEmpty() && !m_lastTask.details.isEmpty())
|
Task t = m_lastTask;
|
||||||
m_lastTask.summary = m_lastTask.details.takeFirst();
|
m_lastTask.clear();
|
||||||
m_lines += m_lastTask.details.count();
|
|
||||||
|
if (t.summary.isEmpty() && !t.details.isEmpty())
|
||||||
|
t.summary = t.details.takeFirst();
|
||||||
|
m_lines += t.details.count();
|
||||||
|
|
||||||
if (m_callStack.has_value() && !m_callStack.value().isEmpty()) {
|
if (m_callStack.has_value() && !m_callStack.value().isEmpty()) {
|
||||||
m_lastTask.file = m_callStack.value().last().file;
|
t.file = m_callStack.value().last().file;
|
||||||
m_lastTask.line = m_callStack.value().last().line;
|
t.line = m_callStack.value().last().line;
|
||||||
|
|
||||||
LinkSpecs specs;
|
LinkSpecs specs;
|
||||||
m_lastTask.details << QString();
|
t.details << QString();
|
||||||
m_lastTask.details << Tr::tr("Call stack:");
|
t.details << Tr::tr("Call stack:");
|
||||||
m_lines += 2;
|
m_lines += 2;
|
||||||
|
|
||||||
m_callStack->push_front(m_errorOrWarningLine);
|
m_callStack->push_front(m_errorOrWarningLine);
|
||||||
|
|
||||||
int offset = m_lastTask.details.join('\n').size();
|
int offset = t.details.join('\n').size();
|
||||||
Utils::reverseForeach(m_callStack.value(), [&](const auto &line) {
|
Utils::reverseForeach(m_callStack.value(), [&](const auto &line) {
|
||||||
const QString fileAndLine = QString("%1:%2").arg(line.file.path()).arg(line.line);
|
const QString fileAndLine = QString("%1:%2").arg(line.file.path()).arg(line.line);
|
||||||
const QString completeLine = QString(" %1%2").arg(fileAndLine).arg(line.function);
|
const QString completeLine = QString(" %1%2").arg(fileAndLine).arg(line.function);
|
||||||
@@ -228,16 +231,14 @@ void CMakeParser::flush()
|
|||||||
int(fileAndLine.length()),
|
int(fileAndLine.length()),
|
||||||
createLinkTarget(line.file, line.line, -1)});
|
createLinkTarget(line.file, line.line, -1)});
|
||||||
|
|
||||||
m_lastTask.details << completeLine;
|
t.details << completeLine;
|
||||||
offset += completeLine.length() - 2;
|
offset += completeLine.length() - 2;
|
||||||
++m_lines;
|
++m_lines;
|
||||||
});
|
});
|
||||||
|
|
||||||
setDetailsFormat(m_lastTask, specs);
|
setDetailsFormat(t, specs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Task t = m_lastTask;
|
|
||||||
m_lastTask.clear();
|
|
||||||
scheduleTask(t, m_lines, 1);
|
scheduleTask(t, m_lines, 1);
|
||||||
m_lines = 0;
|
m_lines = 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user