From 9a16aaf3058001a8fef4d69cf952dd6eba781ac1 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Sat, 20 Sep 2008 21:02:26 +0000 Subject: [PATCH] fix leak and potential crash by disconnecting on delete --- src/selection-describer.cpp | 10 +++++++++- src/selection-describer.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) 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; }; -- 2.30.2