From 44b1fc2051df2bfd784ce847ee430edad68e3dbd Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 19 Mar 2010 09:50:52 +1000 Subject: Fix Flipable crash. Task-number: QTBUG-9161 --- src/declarative/graphicsitems/qdeclarativeflipable.cpp | 7 ++++--- tests/auto/declarative/qdeclarativeflipable/data/crash.qml | 9 +++++++++ .../qdeclarativeflipable/tst_qdeclarativeflipable.cpp | 10 ++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeflipable/data/crash.qml diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp index 1ebbaee..8b46039 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp @@ -42,6 +42,7 @@ #include "qdeclarativeflipable_p.h" #include "qdeclarativeitem_p.h" +#include "qdeclarativeguard_p.h" #include @@ -58,8 +59,8 @@ public: void updateSceneTransformFromParent(); QDeclarativeFlipable::Side current; - QDeclarativeItem *front; - QDeclarativeItem *back; + QDeclarativeGuard front; + QDeclarativeGuard back; }; /*! @@ -192,7 +193,7 @@ void QDeclarativeFlipablePrivate::updateSceneTransformFromParent() if (newSide != current) { current = newSide; - if (current == QDeclarativeFlipable::Back) { + if (current == QDeclarativeFlipable::Back && back) { QTransform mat; mat.translate(back->width()/2,back->height()/2); if (back->width() && p1.x() >= p2.x()) diff --git a/tests/auto/declarative/qdeclarativeflipable/data/crash.qml b/tests/auto/declarative/qdeclarativeflipable/data/crash.qml new file mode 100644 index 0000000..ad40bf0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeflipable/data/crash.qml @@ -0,0 +1,9 @@ +import Qt 4.6 + +Flipable { + transform: Rotation { + axis.y: 1 + axis.z: 0 + angle: 180 + } +} diff --git a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp index ed37c43..04c6710 100644 --- a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp +++ b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,7 @@ private slots: void create(); void checkFrontAndBack(); void setFrontAndBack(); + void crash(); private: QDeclarativeEngine engine; @@ -108,6 +110,14 @@ void tst_qdeclarativeflipable::setFrontAndBack() delete obj; } +void tst_qdeclarativeflipable::crash() +{ + QDeclarativeView *canvas = new QDeclarativeView; + canvas->setSource(QUrl(SRCDIR "/data/crash.qml")); + canvas->show(); + delete canvas; +} + QTEST_MAIN(tst_qdeclarativeflipable) #include "tst_qdeclarativeflipable.moc" -- cgit v0.12