From: buliabyak Date: Sat, 20 Sep 2008 21:02:26 +0000 (+0000) Subject: fix leak and potential crash by disconnecting on delete X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9a16aaf3058001a8fef4d69cf952dd6eba781ac1;p=inkscape.git fix leak and potential crash by disconnecting on delete --- diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 6d80cfe5c..bd8403054 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -97,10 +97,18 @@ namespace Inkscape { SelectionDescriber::SelectionDescriber(Inkscape::Selection *selection, MessageStack *stack) : _context(stack) { - selection->connectChanged(sigc::mem_fun(*this, &SelectionDescriber::_updateMessageFromSelection)); + _selection_changed_connection = new sigc::connection ( + selection->connectChanged( + sigc::mem_fun(*this, &SelectionDescriber::_updateMessageFromSelection))); _updateMessageFromSelection(selection); } +SelectionDescriber::~SelectionDescriber() +{ + _selection_changed_connection->disconnect(); + delete _selection_changed_connection; +} + void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { GSList const *items = selection->itemList(); diff --git a/src/selection-describer.h b/src/selection-describer.h index cd892bd14..91948c2fd 100644 --- a/src/selection-describer.h +++ b/src/selection-describer.h @@ -24,10 +24,13 @@ class MessageStack; class SelectionDescriber : public sigc::trackable { public: SelectionDescriber(Inkscape::Selection *selection, MessageStack *stack); + ~SelectionDescriber(); private: void _updateMessageFromSelection(Inkscape::Selection *selection); + sigc::connection *_selection_changed_connection; + MessageContext _context; };