Code

switch to sigc++ signals for "release"
authormental <mental@users.sourceforge.net>
Fri, 21 Jul 2006 21:16:41 +0000 (21:16 +0000)
committermental <mental@users.sourceforge.net>
Fri, 21 Jul 2006 21:16:41 +0000 (21:16 +0000)
ChangeLog
src/uri-references.cpp
src/uri-references.h

index e3b8437820e9e65566e79739634f078ef1476afe..fb82617144e84327cc01ef5bdec7b52f22d9579b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,21 +1,11 @@
 2006-07-21  MenTaLguY  <mental@rydia.net>
 
-       * src/document-subset.cpp:
-
-         switch to sigc++ signal for "release"
-
-2006-07-21  MenTaLguY  <mental@rydia.net>
-
-       * 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  <mental@rydia.net>
-
-       * src/ui/view/edit-widget.cpp, src/ui/view/edit-widget.cpp:
-
-         switched to using sigc++ "modified" signal
-
 2006-07-21  MenTaLguY  <mental@rydia.net>
 
        * src/document.cpp, src/sp-object.cpp, src/sp-object.h:
index fff985139b1f6c9071ec54d07d5fc843b65c6a8d..793e10d98ad0ec280e02a093c746107211655c0d 100644 (file)
@@ -17,6 +17,8 @@
 #include "uri.h"
 #include "uri-references.h"
 
+#include <sigc++/functors/mem_fun.h>
+
 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<gpointer>(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<gpointer>(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 */
index 8d4bf70980547b167fd86b874b851fc5b02f4a39..38f346987933ba810e50b6093f9dc5166b550414 100644 (file)
@@ -119,13 +119,14 @@ protected:
 private:
        SPObject *_owner;
        sigc::connection _connection;
+       sigc::connection _release_connection;
        SPObject *_obj;
        URI *_uri;
 
        sigc::signal<void, SPObject *, SPObject *> _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. */