From 028c0b1cdda9538979c6d1287f55d3536ae412f9 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 23 Jun 2020 08:34:35 +0200 Subject: [PATCH] Plugin install: Fix crash on cancel When the process is aborted, both errorOccurred and then finished is sent. Because of the combination of deleteLater and QueuedConnection this leads to m_process being already nullptr when finished is sent, so add some guards. Change-Id: I446114176f8fa5934b411b39d77c97d6267303fa Reviewed-by: Alessandro Portale --- src/libs/utils/archive.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/utils/archive.cpp b/src/libs/utils/archive.cpp index 54411a4b09d..557cccceb42 100644 --- a/src/libs/utils/archive.cpp +++ b/src/libs/utils/archive.cpp @@ -207,6 +207,8 @@ Archive *Archive::unarchive(const FilePath &src, const FilePath &dest) &QProcess::readyReadStandardOutput, archive, [archive]() { + if (!archive->m_process) + return; archive->outputReceived(QString::fromUtf8(archive->m_process->readAllStandardOutput())); }, Qt::QueuedConnection); @@ -215,6 +217,8 @@ Archive *Archive::unarchive(const FilePath &src, const FilePath &dest) QOverload::of(&QProcess::finished), archive, [archive](int, QProcess::ExitStatus) { + if (!archive->m_process) + return; archive->finished(archive->m_process->exitStatus() == QProcess::NormalExit && archive->m_process->exitCode() == 0); archive->m_process->deleteLater(); @@ -227,6 +231,8 @@ Archive *Archive::unarchive(const FilePath &src, const FilePath &dest) &QProcess::errorOccurred, archive, [archive](QProcess::ProcessError) { + if (!archive->m_process) + return; archive->outputReceived(tr("Command failed.")); archive->finished(false); archive->m_process->deleteLater();