change order of beforeDelete() and clearing selection inside Application::slotDeleteDocument to prevent crashes in case resetting a view provider touches the selection

This commit is contained in:
wmayer
2019-10-01 16:33:37 +02:00
parent 169eacf1ab
commit ea1f96916d

View File

@@ -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)