Fix a crash when converting an integer type to 'subtract'.
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_subtract.cpp
index 0372731..cb43e95 100644 (file)
@@ -75,8 +75,11 @@ ValueNode_Subtract::create(const ValueBase& x)
        {
        case ValueBase::TYPE_NIL:
                return value_node;
-       case ValueBase::TYPE_ANGLE:
        case ValueBase::TYPE_COLOR:
+               value_node->set_link("lhs",ValueNode_Const::create(x.get(Color())));
+               value_node->set_link("rhs",ValueNode_Const::create(Color(0,0,0,0)));
+               break;
+       case ValueBase::TYPE_ANGLE:
        case ValueBase::TYPE_INTEGER:
        case ValueBase::TYPE_REAL:
        case ValueBase::TYPE_VECTOR:
@@ -194,7 +197,7 @@ synfig::ValueNode_Subtract::operator()(Time t)const
        if(get_type()==ValueBase::TYPE_COLOR)
                return ((*ref_a)(t).get(Color())-(*ref_b)(t).get(Color()))*(*scalar)(t).get(Real());
        if(get_type()==ValueBase::TYPE_INTEGER)
-               return ((*ref_a)(t).get(int())-(*ref_b)(t).get(int()))*(*scalar)(t).get(Real());
+               return static_cast<int>(((*ref_a)(t).get(int())-(*ref_b)(t).get(int()))*(*scalar)(t).get(Real()) + 0.5f);
        if(get_type()==ValueBase::TYPE_REAL)
                return ((*ref_a)(t).get(Vector::value_type())-(*ref_b)(t).get(Vector::value_type()))*(*scalar)(t).get(Real());
        if(get_type()==ValueBase::TYPE_VECTOR)