From dee10204f91fe6e0838b155b88c7f6669b68e931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 21 Jan 2018 22:14:01 +0100 Subject: [PATCH] SceneGraph: test crash and burn when deleting a running animable. Yes. It does. --- src/Magnum/SceneGraph/Test/AnimableTest.cpp | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Magnum/SceneGraph/Test/AnimableTest.cpp b/src/Magnum/SceneGraph/Test/AnimableTest.cpp index 248dded00..61ad2a061 100644 --- a/src/Magnum/SceneGraph/Test/AnimableTest.cpp +++ b/src/Magnum/SceneGraph/Test/AnimableTest.cpp @@ -42,6 +42,8 @@ struct AnimableTest: TestSuite::Tester { void stop(); void pause(); + void deleteWhileRunning(); + void debug(); }; @@ -55,6 +57,8 @@ AnimableTest::AnimableTest() { &AnimableTest::stop, &AnimableTest::pause, + &AnimableTest::deleteWhileRunning, + &AnimableTest::debug}); } @@ -351,6 +355,28 @@ void AnimableTest::pause() { CORRADE_COMPARE(animable.time, 2.0f); } +void AnimableTest::deleteWhileRunning() { + Object3D object; + AnimableGroup3D group; + CORRADE_COMPARE(group.runningCount(), 0); + + { + OneShotAnimable animable(object, &group); + + /* Eat up some absolute time */ + group.step(1.0f, 0.5f); + group.step(1.5f, 0.5f); + CORRADE_COMPARE(group.runningCount(), 1); + + CORRADE_COMPARE(animable.state(), AnimationState::Running); + CORRADE_COMPARE(animable.time, 0.5f); + } + + /* Animable got deleted, stepping further should not crash and burn (tm) */ + group.step(1.5f, 0.5f); + CORRADE_COMPARE(group.runningCount(), 0); +} + void AnimableTest::debug() { std::ostringstream o; Debug(&o) << AnimationState::Running << AnimationState(0xbe);