]> git.tdb.fi Git - libs/gl.git/blobdiff - source/animation.cpp
Don't allow iterators on empty animations
[libs/gl.git] / source / animation.cpp
index b58a4ea77e0e0c3193c2eec31074aa91912b72c7..1cfb533f94eb3cd901ecba9dc501d28433224a15 100644 (file)
@@ -61,6 +61,8 @@ void Animation::add_keyframe(const Time::TimeDelta &t, const KeyFrame &kf, float
 
 void Animation::add_keyframe(const Time::TimeDelta &t, const RefPtr<const KeyFrame> &kf, float ss, float es)
 {
+       if(keyframes.empty() && t!=Time::zero)
+               throw invalid_argument("Animation::add_keyframe");
        if(!keyframes.empty() && t<keyframes.back().time)
                throw invalid_argument("Animation::add_keyframe");
 
@@ -270,7 +272,10 @@ Animation::Iterator::Iterator(const Animation &a):
        event_iter(animation->events.begin()),
        x(0),
        end(false)
-{ }
+{
+       if(iter==animation->keyframes.end())
+               throw invalid_argument("Animation::Iterator::Iterator");
+}
 
 Animation::Iterator &Animation::Iterator::operator+=(const Time::TimeDelta &t)
 {