aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@rim.com>2013-02-26 13:50:51 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-12 23:25:37 +0100
commitfa8a4beb157f82e02cf8471ade7da0faee7a9fa1 (patch)
tree8115a2e936dda9b292a769c4c0e6f076d904f1ca /src
parentc460a83e26c6ade557dac9cf30df6a95cb1aadd2 (diff)
Fix remote image loading for AnimatedSprite
The Sprite generated behind the scenes had no QmlEngine associated, and the engine is needed by QQuickPixmap for async loading. Task-number: QTBUG-28086 Change-Id: Ibf3b03c54b339fe8f44201dc6fcb507e5274bbec Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp4
-rw-r--r--src/quick/items/qquicksprite.cpp11
-rw-r--r--src/quick/items/qquickspriteengine.cpp1
3 files changed, 12 insertions, 4 deletions
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index 343cac5d5c..f09e9bb90e 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -365,7 +365,7 @@ QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) :
QQuickItem(parent)
, m_node(0)
, m_material(0)
- , m_sprite(new QQuickSprite)
+ , m_sprite(new QQuickSprite(this))
, m_spriteEngine(0)
, m_curFrame(0)
, m_pleaseReset(false)
@@ -540,7 +540,7 @@ QSGGeometryNode* QQuickAnimatedSprite::buildNode()
m_material = new QQuickAnimatedSpriteMaterial();
- QImage image = m_spriteEngine->assembledImage();
+ QImage image = m_spriteEngine->assembledImage(); //Engine prints errors if there are any
if (image.isNull())
return 0;
m_sheetSize = QSizeF(image.size());
diff --git a/src/quick/items/qquicksprite.cpp b/src/quick/items/qquicksprite.cpp
index 13593384d8..b4138308f6 100644
--- a/src/quick/items/qquicksprite.cpp
+++ b/src/quick/items/qquicksprite.cpp
@@ -254,8 +254,15 @@ int QQuickSprite::variedDuration() const //Deals with precedence when multiple d
void QQuickSprite::startImageLoading()
{
m_pix.clear(this);
- if (!m_source.isEmpty())
- m_pix.load(qmlEngine(this), m_source);
+ if (!m_source.isEmpty()) {
+ QQmlEngine *e = qmlEngine(this);
+ if (!e) { //If not created in QML, you must set the QObject parent to the QML element so this can work
+ e = qmlEngine(parent());
+ if (!e)
+ qWarning() << "QQuickSprite: Cannot find QQmlEngine - this class is only for use in QML and may not work";
+ }
+ m_pix.load(e, m_source);
+ }
}
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp
index 4c7be3bce9..aa93d31cf7 100644
--- a/src/quick/items/qquickspriteengine.cpp
+++ b/src/quick/items/qquickspriteengine.cpp
@@ -328,6 +328,7 @@ QQuickPixmap::Status QQuickSpriteEngine::status()//Composed status of all Sprite
null = loading = ready = 0;
foreach (QQuickSprite* s, m_sprites) {
switch (s->m_pix.status()) {
+ // ### Maybe add an error message here, because this null shouldn't be reached but when it does, the image fails without an error message.
case QQuickPixmap::Null : null++; break;
case QQuickPixmap::Loading : loading++; break;
case QQuickPixmap::Error : return QQuickPixmap::Error;