aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/archive.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-06-23 08:34:35 +0200
committerEike Ziller <eike.ziller@qt.io>2020-06-23 13:48:02 +0000
commit028c0b1cdda9538979c6d1287f55d3536ae412f9 (patch)
tree083d454dbf18165fa362270f2edcdfa33839b2f5 /src/libs/utils/archive.cpp
parent611a3bb68a5ce4cb77023a953787fb9de105d8cc (diff)
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 <alessandro.portale@qt.io>
Diffstat (limited to 'src/libs/utils/archive.cpp')
-rw-r--r--src/libs/utils/archive.cpp6
1 files changed, 6 insertions, 0 deletions
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<int, QProcess::ExitStatus>::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();