Check that a ValueNode is compatible with the given type before attempting to create it.
[synfig.git] / synfig-core / trunk / src / synfig / valuenode.cpp
index 2611392..2539e5b 100644 (file)
@@ -165,19 +165,19 @@ ValueNode::subsys_stop()
                for(iter=global_value_node_map.begin();iter!=global_value_node_map.end();++iter)
                {
                        if(!iter->second->is_exported())
-                               synfig::info("%s: count:%d name:%s type:%s",
+                               synfig::info(_("%s: count:%d name:%s type:%s"),
                                        iter->first.get_string().c_str(),
                                        iter->second->count(),
                                        iter->second->get_name().c_str(),
-                                       ValueBase::type_name(iter->second->get_type()).c_str()
+                                       ValueBase::type_local_name(iter->second->get_type()).c_str()
                                );
                        else
-                               synfig::info("%s: id:%s count:%d name:%s type:%s",
+                               synfig::info(_("%s: id:%s count:%d name:%s type:%s"),
                                        iter->first.get_string().c_str(),
                                        iter->second->get_id().c_str(),
                                        iter->second->count(),
                                        iter->second->get_name().c_str(),
-                                       ValueBase::type_name(iter->second->get_type()).c_str()
+                                       ValueBase::type_local_name(iter->second->get_type()).c_str()
                                );
                }
        }
@@ -201,6 +201,13 @@ LinkableValueNode::create(const String &name, const ValueBase& x)
 {
        if(!book().count(name))
                return 0;
+
+       if (!check_type(name, x.get_type()))
+       {
+               error(_("Bad type: ValueNode '%s' doesn't accept type '%s'"), book()[name].local_name.c_str(), ValueBase::type_local_name(x.get_type()).c_str());
+               return 0;
+       }
+
        return book()[name].factory(x);
 }
 
@@ -255,8 +262,6 @@ ValueNode::~ValueNode()
        value_node_count--;
 
        begin_delete();
-
-       //DEBUGPOINT();
 }
 
 void