From: dooglus Date: Fri, 21 Sep 2007 15:05:51 +0000 (+0000) Subject: Fix 1368694. You can now add layers to groups and the groups show up immediately... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=493ba873017ae66e23031e3caf949466960dc971;p=synfig.git Fix 1368694. You can now add layers to groups and the groups show up immediately. The rest of the groups dialog is still pretty broken, but there are other bug reports about that. git-svn-id: http://svn.voria.com/code@731 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/canvas.cpp b/synfig-core/trunk/src/synfig/canvas.cpp index e98b301..035208d 100644 --- a/synfig-core/trunk/src/synfig/canvas.cpp +++ b/synfig-core/trunk/src/synfig/canvas.cpp @@ -700,24 +700,22 @@ Canvas::insert(iterator iter,etl::handle x) //while(correct_canvas->is_inline())correct_canvas=correct_canvas->parent(); Layer::LooseHandle loose_layer(x); - x->signal_added_to_group().connect( - sigc::bind( - sigc::mem_fun( - *correct_canvas, - &Canvas::add_group_pair - ), - loose_layer - ) - ); - x->signal_removed_from_group().connect( - sigc::bind( - sigc::mem_fun( - *correct_canvas, - &Canvas::remove_group_pair - ), - loose_layer - ) - ); + add_connection(x, + sigc::connection::connection( + x->signal_added_to_group().connect( + sigc::bind( + sigc::mem_fun( + *correct_canvas, + &Canvas::add_group_pair), + loose_layer)))); + add_connection(x, + sigc::connection::connection( + x->signal_removed_from_group().connect( + sigc::bind( + sigc::mem_fun( + *correct_canvas, + &Canvas::remove_group_pair), + loose_layer)))); if(!x->get_group().empty()) @@ -749,8 +747,10 @@ Canvas::erase(Canvas::iterator iter) // is using these signals, so I'll just // leave these next two lines like they // are for now - darco 07-30-2004 - (*iter)->signal_added_to_group().clear(); - (*iter)->signal_removed_from_group().clear(); + + // so don't wipe them out entirely + // - dooglus 09-21-2007 + disconnect_connections(*iter); if(!op_flag_)remove_child(iter->get()); @@ -1179,6 +1179,21 @@ Canvas::remove_group_pair(String group, etl::handle layer) } void +Canvas::add_connection(etl::handle layer, sigc::connection connection) +{ + connections_[layer].push_back(connection); +} + +void +Canvas::disconnect_connections(etl::handle layer) +{ + std::vector::iterator iter; + for(iter=connections_[layer].begin();iter!=connections_[layer].end();++iter) + iter->disconnect(); + connections_[layer].clear(); +} + +void Canvas::rename_group(const String&old_name,const String&new_name) { if(is_inline() && parent_) diff --git a/synfig-core/trunk/src/synfig/canvas.h b/synfig-core/trunk/src/synfig/canvas.h index 470b7c9..972b6cf 100644 --- a/synfig-core/trunk/src/synfig/canvas.h +++ b/synfig-core/trunk/src/synfig/canvas.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "vector.h" #include "string.h" @@ -141,6 +142,9 @@ private: //! Layer Group database std::map > > group_db_; + //! Layer Connection database + std::map,std::vector > connections_; + /* -- ** -- S I G N A L S ------------------------------------------------------- */ @@ -469,6 +473,8 @@ public: private: void add_group_pair(String group, etl::handle layer); void remove_group_pair(String group, etl::handle layer); + void add_connection(etl::handle layer, sigc::connection connection); + void disconnect_connections(etl::handle layer); protected: virtual void on_changed();