Commit 94d345e0 authored by Stefano Facchini's avatar Stefano Facchini Committed by Patrick Storz
Browse files

Unset the current tool early on shutdown.

Before this commit, when the application is terminated we call the
::finish() method for the current tool, only after deleting the
selection and other objects. But it may happen that the tool's finish()
assume that the selection is still alive, making the application crash.
(For instance, with the Bezier tool when the path is still not closed).

Instead, unset the current tool early, when the Desktop object is
removed from the application, before calling its ::destroy() method.

(backported from 2adf86d2, minor edit)
parent 4a473ad3
Pipeline #82310800 passed with stages
in 37 minutes and 24 seconds
......@@ -337,7 +337,6 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
snapindicator = new Inkscape::Display::SnapIndicator ( this );
}
void SPDesktop::destroy()
{
_destroy_signal.emit(this);
......@@ -346,6 +345,7 @@ void SPDesktop::destroy()
delete snapindicator;
snapindicator = NULL;
}
if (temporary_item_list) {
delete temporary_item_list;
temporary_item_list = NULL;
......@@ -371,12 +371,6 @@ void SPDesktop::destroy()
g_signal_handlers_disconnect_by_func(G_OBJECT (main), (gpointer) G_CALLBACK(sp_desktop_root_handler), this);
g_signal_handlers_disconnect_by_func(G_OBJECT (drawing), (gpointer) G_CALLBACK(_arena_handler), this);
if (event_context) {
event_context->finish();
delete event_context;
event_context = NULL;
}
delete layers;
if (layer_manager) {
......@@ -687,7 +681,7 @@ void SPDesktop::setEventContext(const std::string& toolName)
}
if (toolName.empty()) {
event_context = nullptr;
event_context = NULL;
} else {
event_context = ToolFactory::createObject(toolName);
event_context->desktop = this;
......
......@@ -1698,7 +1698,9 @@ void SPDocument::setModifiedSinceSave(bool modified) {
Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel();
if (parent) { // during load, SP_ACTIVE_DESKTOP may be !nullptr, but parent might still be nullptr
SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget"));
dtw->updateTitle( this->getName() );
if (dtw) {
dtw->updateTitle( this->getName() );
}
}
}
}
......
......@@ -829,6 +829,8 @@ Application::remove_desktop (SPDesktop * desktop)
g_error("Attempted to remove desktop not in list.");
}
desktop->setEventContext("");
if (DESKTOP_IS_ACTIVE (desktop)) {
signal_deactivate_desktop.emit(desktop);
if (_desktops->size() > 1) {
......
......@@ -849,10 +849,9 @@ static void sp_desktop_widget_dispose(GObject *object)
g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw);
g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas_tbl), (gpointer) G_CALLBACK (canvas_tbl_size_allocate), dtw);
dtw->layer_selector->setDesktop(NULL);
dtw->layer_selector->unreference();
INKSCAPE.remove_desktop (dtw->desktop); // clears selection too
INKSCAPE.remove_desktop(dtw->desktop); // clears selection and event_context
dtw->modified_connection.disconnect();
dtw->desktop->destroy();
Inkscape::GC::release (dtw->desktop);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment