From 0a603a1e7a1d021e5e25515f6ca592219952f95d Mon Sep 17 00:00:00 2001 From: mental Date: Fri, 21 Jul 2006 21:16:41 +0000 Subject: [PATCH] switch to sigc++ signals for "release" --- ChangeLog | 18 ++++-------------- src/uri-references.cpp | 12 +++++++----- src/uri-references.h | 3 ++- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3b843782..fb8261714 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,21 +1,11 @@ 2006-07-21 MenTaLguY - * src/document-subset.cpp: - - switch to sigc++ signal for "release" - -2006-07-21 MenTaLguY - - * src/selection.cpp, src/selection.h: - + * src/document-subset.cpp, src/selection.cpp, src/selection.h, + src/ui/view/edit-widget.cpp, src/ui/view/edit-widget.h, + src/uri-references.cpp, src/uri-references.h: + switch to sigc++ signals for "modified" and "release" -2006-07-21 MenTaLguY - - * src/ui/view/edit-widget.cpp, src/ui/view/edit-widget.cpp: - - switched to using sigc++ "modified" signal - 2006-07-21 MenTaLguY * src/document.cpp, src/sp-object.cpp, src/sp-object.h: diff --git a/src/uri-references.cpp b/src/uri-references.cpp index fff985139..793e10d98 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -17,6 +17,8 @@ #include "uri.h" #include "uri-references.h" +#include + static gchar *uri_to_id(SPDocument *document, const gchar *uri); namespace Inkscape { @@ -97,12 +99,12 @@ void URIReference::_setObject(SPObject *obj) { if (_obj) { sp_object_href(_obj, _owner); - g_signal_connect(G_OBJECT(_obj), "release", G_CALLBACK(&URIReference::_release), reinterpret_cast(this)); + _release_connection = _obj->connectRelease(sigc::mem_fun(*this, &URIReference::_release)); } _changed_signal.emit(old_obj, _obj); if (old_obj) { + _release_connection.disconnect(); /* release the old object _after_ the signal emission */ - g_signal_handlers_disconnect_by_func(G_OBJECT(old_obj), (void *)&URIReference::_release, reinterpret_cast(this)); sp_object_hunref(old_obj, _owner); } } @@ -111,9 +113,9 @@ void URIReference::_setObject(SPObject *obj) { * it on its "release" signal, rather than later, when its ID is actually * unregistered from the document. */ -void URIReference::_release(SPObject *obj, URIReference *reference) { - g_assert( reference->_obj == obj ); - reference->_setObject(NULL); +void URIReference::_release(SPObject *obj) { + g_assert( _obj == obj ); + _setObject(NULL); } } /* namespace Inkscape */ diff --git a/src/uri-references.h b/src/uri-references.h index 8d4bf7098..38f346987 100644 --- a/src/uri-references.h +++ b/src/uri-references.h @@ -119,13 +119,14 @@ protected: private: SPObject *_owner; sigc::connection _connection; + sigc::connection _release_connection; SPObject *_obj; URI *_uri; sigc::signal _changed_signal; void _setObject(SPObject *object); - static void _release(SPObject *object, URIReference *reference); + void _release(SPObject *object); void operator=(const URIReference &ref); /* Private and definition-less to prevent accidental use. */ -- 2.30.2