From: dooglus Date: Mon, 7 Jan 2008 12:59:56 +0000 (+0000) Subject: When cloning a duplicate layer, always make a new 'Index' parameter, even if the... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=3174d697b7c970d74d239984f6cd699600952b3c;p=synfig.git When cloning a duplicate layer, always make a new 'Index' parameter, even if the cloned layer has it exported. Otherwise we can get an infinite loop. git-svn-id: http://svn.voria.com/code@1277 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/layer_duplicate.cpp b/synfig-core/trunk/src/synfig/layer_duplicate.cpp index cb6ccb4..5a8719d 100644 --- a/synfig-core/trunk/src/synfig/layer_duplicate.cpp +++ b/synfig-core/trunk/src/synfig/layer_duplicate.cpp @@ -67,6 +67,24 @@ Layer_Duplicate::Layer_Duplicate(): connect_dynamic_param("index", index_value_node); } +Layer::Handle +Layer_Duplicate::clone(const GUID& deriv_guid)const +{ + printf("cloning layer duplicate\n"); + Layer::Handle ret = (Layer::Handle)Layer_Composite::clone(deriv_guid); + + const DynamicParamList &dpl = dynamic_param_list(); + DynamicParamList::const_iterator iter = dpl.find("index"); + + // if we have a dynamic "index" parameter, make a new one in the clone + // it's not good to have two references to the same index valuenode, + // or nested duplicatations cause an infinite loop + if (iter != dpl.end()) + ret->connect_dynamic_param(iter->first,iter->second->clone(deriv_guid)); + + return ret; +} + bool Layer_Duplicate::set_param(const String ¶m, const ValueBase &value) { @@ -119,6 +137,16 @@ Layer_Duplicate::get_param_vocab()const return ret; } +ValueNode_Duplicate::Handle +Layer_Duplicate::get_duplicate_param()const +{ + const DynamicParamList &dpl = dynamic_param_list(); + DynamicParamList::const_iterator iter = dpl.find("index"); + if (iter == dpl.end()) return NULL; + etl::rhandle param(iter->second); + return ValueNode_Duplicate::Handle::cast_dynamic(param); +} + bool Layer_Duplicate::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const { @@ -136,16 +164,8 @@ Layer_Duplicate::accelerated_render(Context context,Surface *surface,int quality Surface tmp; int i = 0; - const DynamicParamList &dpl = dynamic_param_list(); - DynamicParamList::const_iterator iter = dpl.find("index"); - if (iter == dpl.end()) - return context.accelerated_render(surface,quality,renddesc,cb); - - etl::rhandle param(iter->second); - handle duplicate_param(handle::cast_dynamic(param)); - - if (!duplicate_param) - return context.accelerated_render(surface,quality,renddesc,cb); + handle duplicate_param = get_duplicate_param(); + if (!duplicate_param) return context.accelerated_render(surface,quality,renddesc,cb); surface->set_wh(renddesc.get_w(),renddesc.get_h()); surface->clear(); diff --git a/synfig-core/trunk/src/synfig/layer_duplicate.h b/synfig-core/trunk/src/synfig/layer_duplicate.h index bbe2cde..6d74c18 100644 --- a/synfig-core/trunk/src/synfig/layer_duplicate.h +++ b/synfig-core/trunk/src/synfig/layer_duplicate.h @@ -47,6 +47,9 @@ public: Layer_Duplicate(); + //! Duplicates the Layer + virtual Layer::Handle clone(const GUID& deriv_guid=GUID())const; + virtual bool set_param(const String & param, const synfig::ValueBase &value); virtual ValueBase get_param(const String & param)const; @@ -57,6 +60,8 @@ public: virtual void set_time(Context context, Time time, const Point &point)const; + virtual ValueNode_Duplicate::Handle get_duplicate_param()const; + virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const; virtual Vocab get_param_vocab()const;