Commit 5201fb42 authored by Milian Wolff's avatar Milian Wolff
Browse files

Don't crash after killing CTestFindJob

The m_suite might have been deleted at that point already, so it's
not safe to try to output it's name anymore. Change the logic to
instead unset the m_suite member and don't try to access it once
unset anymore.

Fixes:
```
Thread 1 "kdevelop" received signal SIGSEGV, Segmentation fault.
0x00007fff3949a9b0 in CTestFindJob::updateReady (this=0x55555a60e770, document=..., context=...) at /home/milian/projects/kde/src/kdevelop/plugins/cmake/testing/ctestfindjob.cpp:64
64              qCDebug(CMAKE) << "Cannot add test suite" << m_suite->name() << ": this job has been killed.";
(gdb) p m_suite
$1 = (CTestSuite *) 0x55555a6057b0
```
parent 2fbd2d3d
......@@ -56,12 +56,8 @@ void CTestFindJob::findTestCases()
void CTestFindJob::updateReady(const KDevelop::IndexedString& document, const KDevelop::ReferencedTopDUContext& context)
{
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 75, 0)
if (Q_UNLIKELY(isFinished())) {
#else
if (Q_UNLIKELY(error() == KilledJobError)) {
#endif
qCDebug(CMAKE) << "Cannot add test suite" << m_suite->name() << ": this job has been killed.";
if (!m_suite) {
// killed or done already
return;
}
......@@ -77,12 +73,14 @@ void CTestFindJob::updateReady(const KDevelop::IndexedString& document, const KD
m_pendingFiles.removeAll(KDevelop::Path(document.toUrl()));
if (m_pendingFiles.isEmpty()) {
m_suite = nullptr;
emitResult();
}
}
bool CTestFindJob::doKill()
{
m_suite = nullptr;
KDevelop::ICore::self()->languageController()->backgroundParser()->revertAllRequests(this);
return true;
}
Supports Markdown
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