GH-2485 fix crash bug while creating instances

This commit is contained in:
Petr Mrázek 2018-12-14 01:18:18 +01:00
parent 075e173fbd
commit 14bb666a20
3 changed files with 6 additions and 8 deletions

View File

@ -718,7 +718,7 @@ public:
// FIXME/TODO: add ability to abort during instance commit retries // FIXME/TODO: add ability to abort during instance commit retries
bool abort() override bool abort() override
{ {
if(m_child) if(m_child && m_child->canAbort())
{ {
return m_child->abort(); return m_child->abort();
} }
@ -726,9 +726,9 @@ public:
} }
bool canAbort() const override bool canAbort() const override
{ {
if(m_child) if(m_child && m_child->canAbort())
{ {
return m_child->canAbort(); return true;
} }
return false; return false;
} }
@ -746,7 +746,6 @@ protected:
private slots: private slots:
void childSucceded() void childSucceded()
{ {
m_child.reset();
unsigned sleepTime = backoff(); unsigned sleepTime = backoff();
if(m_parent->commitStagedInstance(m_stagingPath, m_instanceName, m_groupName)) if(m_parent->commitStagedInstance(m_stagingPath, m_instanceName, m_groupName))
{ {
@ -764,7 +763,6 @@ private slots:
} }
void childFailed(const QString & reason) void childFailed(const QString & reason)
{ {
m_child.reset();
m_parent->destroyStagingPath(m_stagingPath); m_parent->destroyStagingPath(m_stagingPath);
emitFailed(reason); emitFailed(reason);
} }

View File

@ -1283,7 +1283,7 @@ void MainWindow::runModalTask(Task *task)
void MainWindow::instanceFromInstanceTask(InstanceTask *rawTask) void MainWindow::instanceFromInstanceTask(InstanceTask *rawTask)
{ {
std::unique_ptr<Task> task(MMC->instances()->wrapInstanceTask(rawTask)); unique_qobject_ptr<Task> task(MMC->instances()->wrapInstanceTask(rawTask));
runModalTask(task.get()); runModalTask(task.get());
} }
@ -1300,7 +1300,7 @@ void MainWindow::on_actionCopyInstance_triggered()
copyTask->setName(copyInstDlg.instName()); copyTask->setName(copyInstDlg.instName());
copyTask->setGroup(copyInstDlg.instGroup()); copyTask->setGroup(copyInstDlg.instGroup());
copyTask->setIcon(copyInstDlg.iconKey()); copyTask->setIcon(copyInstDlg.iconKey());
std::unique_ptr<Task> task(MMC->instances()->wrapInstanceTask(copyTask)); unique_qobject_ptr<Task> task(MMC->instances()->wrapInstanceTask(copyTask));
runModalTask(task.get()); runModalTask(task.get());
} }

View File

@ -40,7 +40,7 @@ void LegacyUpgradePage::on_upgradeButton_clicked()
upgradeTask->setName(newName); upgradeTask->setName(newName);
upgradeTask->setGroup(MMC->instances()->getInstanceGroup(m_inst->id())); upgradeTask->setGroup(MMC->instances()->getInstanceGroup(m_inst->id()));
upgradeTask->setIcon(m_inst->iconKey()); upgradeTask->setIcon(m_inst->iconKey());
std::unique_ptr<Task> task(MMC->instances()->wrapInstanceTask(upgradeTask)); unique_qobject_ptr<Task> task(MMC->instances()->wrapInstanceTask(upgradeTask));
runModalTask(task.get()); runModalTask(task.get());
} }