From ea1f96916df3039dc5bfe4a85bc09a84b62f9b6b Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 1 Oct 2019 16:33:37 +0200 Subject: [PATCH] change order of beforeDelete() and clearing selection inside Application::slotDeleteDocument to prevent crashes in case resetting a view provider touches the selection --- src/Gui/Application.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 3961ef6253..e3f6b9420b 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -720,6 +720,10 @@ void Application::slotDeleteDocument(const App::Document& Doc) return; } + // Inside beforeDelete() a view provider may finish editing mode + // and therefore can alter the selection. + doc->second->beforeDelete(); + // We must clear the selection here to notify all observers. // And because of possible cross document link, better clear all selection // to be safe @@ -727,8 +731,6 @@ void Application::slotDeleteDocument(const App::Document& Doc) doc->second->signalDeleteDocument(*doc->second); signalDeleteDocument(*doc->second); - doc->second->beforeDelete(); - // If the active document gets destructed we must set it to 0. If there are further existing documents then the // view that becomes active sets the active document again. So, we needn't worry about this. if (d->activeDocument == doc->second)