Commit ae9f45ae authored by Igor Kushnir's avatar Igor Kushnir

Early-return from CTestFindJob::updateReady() if the job is finished

When a user exits KDevelop while a CTestFindJob is still working, the
job is killed from RunController::cleanup() and its KJob parent calls
deleteLater(). But the killed job can be still not destroyed after
DUChain::shutdown() is called, which results in a crash if
CTestFindJob::updateReady() is then invoked via Qt::QueuedConnection.
Note that ~ParseJob() queues calls to CTestFindJob::updateReady(),
which can then be invoked after DUChain::shutdown(), if ParseJob-s are
running when the user exits KDevelop and no event loop is entered in the
time between the ~ParseJob() and DUChain::shutdown() calls (sometimes
the optional QCoreApplication::processEvents() call in
BackgroundParser::waitForIdle() intervenes and prevents the crash).
Core::cleanup() calls backgroundParser()->waitForIdle(), which ensures
that all parse jobs finish, are destroyed and queue "updateReady" calls.

BUG: 423651
FIXED-IN: 5.6.1
parent 62a336eb
......@@ -27,6 +27,7 @@
#include <language/duchain/duchain.h>
#include <language/backgroundparser/backgroundparser.h>
#include <kcoreaddons_version.h>
#include <KLocalizedString>
CTestFindJob::CTestFindJob(CTestSuite* suite, QObject* parent)
......@@ -78,6 +79,15 @@ void CTestFindJob::findTestCases()
void CTestFindJob::updateReady(const KDevelop::IndexedString& document, const KDevelop::ReferencedTopDUContext& context)
if (Q_UNLIKELY(isFinished())) {
if (Q_UNLIKELY(error() == KilledJobError)) {
qCDebug(CMAKE) << "Cannot add test suite" << m_suite->name() << ": this job has been killed.";
qCDebug(CMAKE) << "context update ready" << m_pendingFiles << document.str();
m_suite->loadDeclarations(document, context);
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