From 910766458de68c37c8c4dab13c584c4c68502cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 14 Apr 2017 10:41:52 +0200 Subject: GH-1854 prevent a crash if the instance is closed while the kill confirmation dialog is open --- application/MultiMC.cpp | 3 ++- application/MultiMC.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 942b1d93..42f0c93d 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -1001,7 +1001,8 @@ bool MultiMC::kill(InstancePtr instance) return false; } auto & extras = m_instanceExtras[instance->id()]; - auto & controller = extras.controller; + // NOTE: copy of the shared pointer keeps it alive + auto controller = extras.controller; if(controller) { return controller->abort(); diff --git a/application/MultiMC.h b/application/MultiMC.h index a9cbdec7..28a9641a 100644 --- a/application/MultiMC.h +++ b/application/MultiMC.h @@ -214,7 +214,7 @@ private: struct InstanceXtras { InstanceWindow * window = nullptr; - unique_qobject_ptr controller; + shared_qobject_ptr controller; }; std::map m_instanceExtras; size_t m_openWindows = 0; -- cgit v1.2.3