Fix a issue with Editor's slots: when an Editor is destroyed, we have to remove all slots from signals.

This commit is contained in:
David Capello 2010-11-28 15:42:29 -03:00
parent 7f425c8acb
commit fa4d98d599
2 changed files with 12 additions and 1 deletions

View File

@ -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<void>* m_currentToolChangeSlot;
public:
// in editor.c

View File

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