From: mental Date: Fri, 21 Jul 2006 21:49:37 +0000 (+0000) Subject: switch to sigc++ signals and manually clean up signal connections (although it may... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c0ad9a2e35be02bb66552e03f392fe02b57bda7b;p=inkscape.git switch to sigc++ signals and manually clean up signal connections (although it may not be strictly necessary to do so here) --- diff --git a/ChangeLog b/ChangeLog index 23dafb1ea..3839320b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-07-21 MenTaLguY + + * 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 * src/document-subset.cpp, src/object-hierarchy.cpp, diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index 61b0e15bb..4d92d37c8 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -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); diff --git a/src/layer-manager.h b/src/layer-manager.h index fa710e938..0dec95c97 100644 --- a/src/layer-manager.h +++ b/src/layer-manager.h @@ -14,6 +14,7 @@ #include "gc-finalized.h" #include "gc-soft-ptr.h" #include +#include 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();