Fix 1947076: Infinite error message loop on split tangents.
[synfig.git] / synfig-studio / trunk / src / synfigapp / canvasinterface.cpp
index 0677669..40d14df 100644 (file)
@@ -41,6 +41,7 @@
 #include <synfig/valuenode_reference.h>
 #include <synfig/valuenode_twotone.h>
 #include <synfig/valuenode_stripes.h>
+#include <synfig/valuenode_bline.h>
 
 #include <synfig/waypoint.h>
 #include <synfig/loadcanvas.h>
@@ -234,9 +235,30 @@ CanvasInterface::add_layer_to(synfig::String name, synfig::Canvas::Handle canvas
                {
                        ValueNode::Handle value_node;
 
-                       // if we find any which are list values then make them into dynamic list valuenodes
+                       // if we find any which are list values then make them
+                       // into dynamic list valuenodes, unless every element of
+                       // the list is a blinepoint, in which case convert it to a
+                       // bline
                        if(iter->second.get_type()==ValueBase::TYPE_LIST)
-                               value_node=LinkableValueNode::create("dynamic_list",iter->second);
+                       {
+                               // check whether it's a list of blinepoints only
+                               vector<ValueBase> list(iter->second.get_list());
+                               if (list.size())
+                               {
+                                       vector<ValueBase>::iterator iter2;
+                                       for (iter2 = list.begin(); iter2 != list.end(); iter2++)
+                                               if (iter2->get_type() != ValueBase::TYPE_BLINEPOINT)
+                                                       break;
+                                       if (iter2 == list.end())
+                                       {
+                                               value_node=LinkableValueNode::create("bline",iter->second);
+                                               ValueNode_BLine::Handle::cast_dynamic(value_node)->set_member_canvas(canvas);
+                                       }
+                               }
+
+                               if (!value_node)
+                                       value_node=LinkableValueNode::create("dynamic_list",iter->second);
+                       }
                        // otherwise, if it's a type that can be converted to
                        // 'composite' (other than the types that can be radial
                        // composite) then do so
@@ -455,30 +477,59 @@ CanvasInterface::set_rend_desc(const synfig::RendDesc &rend_desc)
                get_ui_interface()->error(_("Action Failed."));
 }
 
-bool
+void
 CanvasInterface::set_name(const synfig::String &x)
 {
-       //! \todo This needs to be converted into an action
-       get_canvas()->set_name(x);
+       Action::Handle  action(Action::create("canvas_name_set"));
+
+       assert(action);
+       if(!action)
+               return;
+
+       action->set_param("canvas",get_canvas());
+       action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
+       action->set_param("name",x);
+
+       if(!get_instance()->perform_action(action))
+               get_ui_interface()->error(_("Action Failed."));
+
        signal_id_changed_();
-       return true;
 }
 
-bool
+void
 CanvasInterface::set_description(const synfig::String &x)
 {
-       //! \todo This needs to be converted into an action
-       get_canvas()->set_description(x);
-       return true;
+       Action::Handle  action(Action::create("canvas_description_set"));
+
+       assert(action);
+       if(!action)
+               return;
+
+       action->set_param("canvas",get_canvas());
+       action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
+       action->set_param("description",x);
+
+       if(!get_instance()->perform_action(action))
+               get_ui_interface()->error(_("Action Failed."));
 }
 
-bool
+void
 CanvasInterface::set_id(const synfig::String &x)
 {
-       //! \todo This needs to be converted into an action
-       get_canvas()->set_id(x);
+       Action::Handle  action(Action::create("canvas_id_set"));
+
+       assert(action);
+       if(!action)
+               return;
+
+       action->set_param("canvas",get_canvas());
+       action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
+       action->set_param("id",x);
+
+       if(!get_instance()->perform_action(action))
+               get_ui_interface()->error(_("Action Failed."));
+
        signal_id_changed_();
-       return true;
 }
 
 
@@ -731,19 +782,22 @@ CanvasInterface::change_value(synfigapp::ValueDesc value_desc,synfig::ValueBase
                return true;
 
        // If this change needs to take place elsewhere, then so be it.
-       if(value_desc.get_canvas() && value_desc.get_canvas()->get_root()!=get_canvas()->get_root())do
+       if(value_desc.get_canvas())
        {
-               etl::handle<Instance> instance;
-               instance=find_instance(value_desc.get_canvas()->get_root());
-
-               if(instance)
-                       return instance->find_canvas_interface(value_desc.get_canvas())->change_value(value_desc,new_value);
-               else
+               if (value_desc.get_canvas()->get_root() != get_canvas()->get_root())
                {
-                       get_ui_interface()->error(_("The value you are trying to edit is in a composition\nwhich doesn't seem to be open. Open that composition and you\nshould be able to edit this value as normal."));
-                       return false;
+                       etl::handle<Instance> instance;
+                       instance=find_instance(value_desc.get_canvas()->get_root());
+
+                       if(instance)
+                               return instance->find_canvas_interface(value_desc.get_canvas())->change_value(value_desc,new_value);
+                       else
+                       {
+                               get_ui_interface()->error(_("The value you are trying to edit is in a composition\nwhich doesn't seem to be open. Open that composition and you\nshould be able to edit this value as normal."));
+                               return false;
+                       }
                }
-       }while(0);
+       }
 #ifdef _DEBUG
        else
        { synfig::warning("Can't get canvas from value desc...?"); }