Commit 299d93e7 authored by Christian Kandeler's avatar Christian Kandeler

QbsProjectManager: Fix crash on project unloading.

We can't just blindly delete the qbs jobs after cancelling them, as that
is not a synchronous operation.

Task-number: QTCREATORBUG-16273
Change-Id: I29787da857e70404a1be1b4bc54921f5a8ce448b
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 0e331a2e
......@@ -59,18 +59,18 @@ QbsProjectParser::QbsProjectParser(QbsProject *project, QFutureInterface<bool> *
QbsProjectParser::~QbsProjectParser()
{
if (m_qbsSetupProjectJob) {
m_qbsSetupProjectJob->disconnect(this);
m_qbsSetupProjectJob->cancel();
m_qbsSetupProjectJob->deleteLater();
m_qbsSetupProjectJob = 0;
}
if (m_ruleExecutionJob) {
m_ruleExecutionJob->disconnect(this);
m_ruleExecutionJob->cancel();
m_ruleExecutionJob->deleteLater();
m_ruleExecutionJob = 0;
}
const auto deleteJob = [this](qbs::AbstractJob *job) {
if (!job)
return;
if (job->state() == qbs::AbstractJob::StateFinished) {
job->deleteLater();
return;
}
connect(job, &qbs::AbstractJob::finished, job, &qbs::AbstractJob::deleteLater);
job->cancel();
};
deleteJob(m_qbsSetupProjectJob);
deleteJob(m_ruleExecutionJob);
m_fi = 0; // we do not own m_fi, do not delete
}
......
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