diff --git a/src/widgets/editor.h b/src/widgets/editor.h index 45a33c80c..3647a57f4 100644 --- a/src/widgets/editor.h +++ b/src/widgets/editor.h @@ -114,6 +114,12 @@ class Editor : public Widget // user is not moving pixels. PixelsMovement* m_pixelsMovement; + // This slot is used to disconnect the Editor from CurrentToolChange + // signal (because the editor can be destroyed and the application + // still continue running and generating CurrentToolChange + // signals). + Slot0* m_currentToolChangeSlot; + public: // in editor.c diff --git a/src/widgets/editor/editor.cpp b/src/widgets/editor/editor.cpp index fb494f76d..f388ba774 100644 --- a/src/widgets/editor/editor.cpp +++ b/src/widgets/editor/editor.cpp @@ -106,7 +106,8 @@ Editor::Editor() jwidget_focusrest(this, true); - App::instance()->CurrentToolChange.connect(&Editor::onCurrentToolChange, this); + m_currentToolChangeSlot = + App::instance()->CurrentToolChange.connect(&Editor::onCurrentToolChange, this); } Editor::~Editor() @@ -119,6 +120,10 @@ Editor::~Editor() // Destroy all decorators deleteDecorators(); + + // Remove this editor as listener of CurrentToolChange signal. + App::instance()->CurrentToolChange.disconnect(m_currentToolChangeSlot); + delete m_currentToolChangeSlot; } int editor_type()