From 14bb666a207ee76cf302152aa03579a47ef32215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 14 Dec 2018 01:18:18 +0100 Subject: [PATCH] GH-2485 fix crash bug while creating instances --- api/logic/InstanceList.cpp | 8 +++----- application/MainWindow.cpp | 4 ++-- application/pages/instance/LegacyUpgradePage.cpp | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/api/logic/InstanceList.cpp b/api/logic/InstanceList.cpp index a3f2e487..993ae92d 100644 --- a/api/logic/InstanceList.cpp +++ b/api/logic/InstanceList.cpp @@ -718,7 +718,7 @@ public: // FIXME/TODO: add ability to abort during instance commit retries bool abort() override { - if(m_child) + if(m_child && m_child->canAbort()) { return m_child->abort(); } @@ -726,9 +726,9 @@ public: } bool canAbort() const override { - if(m_child) + if(m_child && m_child->canAbort()) { - return m_child->canAbort(); + return true; } return false; } @@ -746,7 +746,6 @@ protected: private slots: void childSucceded() { - m_child.reset(); unsigned sleepTime = backoff(); if(m_parent->commitStagedInstance(m_stagingPath, m_instanceName, m_groupName)) { @@ -764,7 +763,6 @@ private slots: } void childFailed(const QString & reason) { - m_child.reset(); m_parent->destroyStagingPath(m_stagingPath); emitFailed(reason); } diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 78b0a907..f144fcbd 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -1283,7 +1283,7 @@ void MainWindow::runModalTask(Task *task) void MainWindow::instanceFromInstanceTask(InstanceTask *rawTask) { - std::unique_ptr task(MMC->instances()->wrapInstanceTask(rawTask)); + unique_qobject_ptr task(MMC->instances()->wrapInstanceTask(rawTask)); runModalTask(task.get()); } @@ -1300,7 +1300,7 @@ void MainWindow::on_actionCopyInstance_triggered() copyTask->setName(copyInstDlg.instName()); copyTask->setGroup(copyInstDlg.instGroup()); copyTask->setIcon(copyInstDlg.iconKey()); - std::unique_ptr task(MMC->instances()->wrapInstanceTask(copyTask)); + unique_qobject_ptr task(MMC->instances()->wrapInstanceTask(copyTask)); runModalTask(task.get()); } diff --git a/application/pages/instance/LegacyUpgradePage.cpp b/application/pages/instance/LegacyUpgradePage.cpp index 15fd10cc..af800b03 100644 --- a/application/pages/instance/LegacyUpgradePage.cpp +++ b/application/pages/instance/LegacyUpgradePage.cpp @@ -40,7 +40,7 @@ void LegacyUpgradePage::on_upgradeButton_clicked() upgradeTask->setName(newName); upgradeTask->setGroup(MMC->instances()->getInstanceGroup(m_inst->id())); upgradeTask->setIcon(m_inst->iconKey()); - std::unique_ptr task(MMC->instances()->wrapInstanceTask(upgradeTask)); + unique_qobject_ptr task(MMC->instances()->wrapInstanceTask(upgradeTask)); runModalTask(task.get()); }