Code

switch to sigc++ signals and manually clean up signal connections (although it may...
authormental <mental@users.sourceforge.net>
Fri, 21 Jul 2006 21:49:37 +0000 (21:49 +0000)
committermental <mental@users.sourceforge.net>
Fri, 21 Jul 2006 21:49:37 +0000 (21:49 +0000)
ChangeLog
src/layer-manager.cpp
src/layer-manager.h

index 23dafb1eab0aabcd087a21ee8aada01de625f8e4..3839320b8b82d8ed0886afd29cdbf3d69b214a44 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-21  MenTaLguY  <mental@rydia.net>
+
+       * src/layer-manager.cpp, src/layer-manager.h:
+
+         switch to sigc++ signals and manually clean up signal connections
+         (although it may not be strictly necessary to do so here)
+
 2006-07-21  MenTaLguY  <mental@rydia.net>
 
        * src/document-subset.cpp, src/object-hierarchy.cpp,
index 61b0e15bb08cf3c00769f0b830aace539d0b7840..4d92d37c846edf4030e495f9f0bdc24884b1222c 100644 (file)
@@ -30,9 +30,10 @@ using Inkscape::XML::Node;
 
 class LayerManager::LayerWatcher : public Inkscape::XML::NodeObserver {
 public:
-    LayerWatcher(LayerManager* mgr, SPObject* obj) :
+    LayerWatcher(LayerManager* mgr, SPObject* obj, sigc::connection c) :
         _mgr(mgr),
         _obj(obj),
+        _connection(c),
         _lockedAttr(g_quark_from_string("sodipodi:insensitive")),
         _labelAttr(g_quark_from_string("inkscape:label"))
     {}
@@ -51,6 +52,7 @@ public:
 
     LayerManager* _mgr;
     SPObject* _obj;
+    sigc::connection _connection;
     GQuark _lockedAttr;
     GQuark _labelAttr;
 };
@@ -146,12 +148,6 @@ void LayerManager::_setDocument(SPDocument *document) {
     _rebuild();
 }
 
-
-void LayerManager::_objectModifiedCB( SPObject* obj, guint flags, LayerManager* mgr )
-{
-    mgr->_objectModified( obj, flags );
-}
-
 void LayerManager::_objectModified( SPObject* obj, guint flags )
 {
     _details_changed_signal.emit( obj );
@@ -166,6 +162,7 @@ void LayerManager::_rebuild() {
             if ( node ) {
                 node->removeObserver(*one);
             }
+            one->_connection.disconnect();
         }
     }
 
@@ -185,15 +182,16 @@ void LayerManager::_rebuild() {
 
                     // Such may have been the cause of bug 1339397.
                     // See http://sourceforge.net/tracker/index.php?func=detail&aid=1339397&group_id=93438&atid=604306
+
                     SPObject const *higher = curr;
                     while ( higher && (SP_OBJECT_PARENT(higher) != root) ) {
                         higher = SP_OBJECT_PARENT(higher);
                     }
                     Node* node = higher ? SP_OBJECT_REPR(higher) : 0;
                     if ( node && node->parent() ) {
-                        g_signal_connect( G_OBJECT(curr), "modified", G_CALLBACK( _objectModifiedCB ), this );
+                        sigc::connection connection = curr->connectModified(sigc::mem_fun(*this, &LayerManager::_objectModified));
 
-                        LayerWatcher* eye = new LayerWatcher(this, curr);
+                        LayerWatcher *eye = new LayerWatcher(this, curr, connection);
                         _watchers.push_back( eye );
                         SP_OBJECT_REPR(curr)->addObserver(*eye);
 
index fa710e93803883f792bfedab39b397da57a23f3e..0dec95c978b82218ab985715c1f344c9fcc40f73 100644 (file)
@@ -14,6 +14,7 @@
 #include "gc-finalized.h"
 #include "gc-soft-ptr.h"
 #include <vector>
+#include <map>
 
 class SPDesktop;
 class SPDocument;
@@ -41,8 +42,6 @@ private:
     friend class LayerWatcher;
     class LayerWatcher;
 
-    static void _objectModifiedCB( SPObject* obj, guint flags, LayerManager* mgr );
-
     void _objectModified( SPObject* obj, guint flags );
     void _setDocument(SPDocument *document);
     void _rebuild();