From 9c14462bad6c83e85db8960d0f48b42b198189a6 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 1 May 2012 15:17:16 +1000 Subject: [PATCH] Keep m_states and m_sprites synchronized Previously you could have more states than sprites, which could lead to errors because the sprite engine assumes bounds checking was done by the state engine (which only knows the size of the states list). Change-Id: Ie6069caa96d01cc28cc79350e6db5ff4191831a8 Reviewed-by: Martin Jones --- src/quick/items/qquickspriteengine.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp index e6aec06..60d6edd 100644 --- a/src/quick/items/qquickspriteengine.cpp +++ b/src/quick/items/qquickspriteengine.cpp @@ -341,13 +341,20 @@ void QQuickSpriteEngine::startAssemblingImage() return; //This could also trigger the start of the image loading in Sprites, however that currently happens in Sprite::setSource + + QList removals; + foreach (QQuickStochasticState* s, m_states){ QQuickSprite* sprite = qobject_cast(s); - if (sprite) + if (sprite) { m_sprites << sprite; - else + } else { + removals << s; qDebug() << "Error: Non-sprite in QQuickSpriteEngine"; + } } + foreach (QQuickStochasticState* s, removals) + m_states.removeAll(s); m_startedImageAssembly = true; } -- 2.7.4