summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-02-02 01:20:29 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-02-02 01:20:29 (GMT)
commit501180c6fbed0857126da2bb0ff1f17ee35472c6 (patch)
tree74f8b6c25c955e0e23d27dfde4962525c309c7ae
parente09cd7062bb50067eb2d2db9197eb9d4ee170360 (diff)
downloadQt-501180c6fbed0857126da2bb0ff1f17ee35472c6.zip
Qt-501180c6fbed0857126da2bb0ff1f17ee35472c6.tar.gz
Qt-501180c6fbed0857126da2bb0ff1f17ee35472c6.tar.bz2
Make sure we update Loader size if item size changes after creation.
Task-number: QTBUG-17114 Reviewed-by: Bea Lam
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp7
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/QTBUG_17114.qml18
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp13
3 files changed, 37 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 562ef08..6c1f1be 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -59,8 +59,13 @@ QDeclarativeLoaderPrivate::~QDeclarativeLoaderPrivate()
void QDeclarativeLoaderPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry)
{
- if (resizeItem == item)
+ if (resizeItem == item) {
+ if (!updatingSize && newGeometry.width() != oldGeometry.width())
+ itemWidthValid = true;
+ if (!updatingSize && newGeometry.height() != oldGeometry.height())
+ itemHeightValid = true;
_q_updateSize(false);
+ }
QDeclarativeItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry);
}
diff --git a/tests/auto/declarative/qdeclarativeloader/data/QTBUG_17114.qml b/tests/auto/declarative/qdeclarativeloader/data/QTBUG_17114.qml
new file mode 100644
index 0000000..8a49733
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeloader/data/QTBUG_17114.qml
@@ -0,0 +1,18 @@
+import QtQuick 1.1
+
+Rectangle {
+ property real loaderWidth: loader.width
+ property real loaderHeight: loader.height
+ width: 200
+ height: 200
+
+ Loader {
+ id: loader
+ sourceComponent: Item {
+ property real iwidth: 32
+ property real iheight: 32
+ width: iwidth
+ height: iheight
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
index 42746e8..f5218c7 100644
--- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -91,6 +91,7 @@ private slots:
void creationContext();
void QTBUG_16928();
void implicitSize();
+ void QTBUG_17114();
private:
QDeclarativeEngine engine;
@@ -619,6 +620,18 @@ void tst_QDeclarativeLoader::implicitSize()
delete item;
}
+void tst_QDeclarativeLoader::QTBUG_17114()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_17114.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+
+ QCOMPARE(item->property("loaderWidth").toReal(), 32.);
+ QCOMPARE(item->property("loaderHeight").toReal(), 32.);
+
+ delete item;
+}
+
QTEST_MAIN(tst_QDeclarativeLoader)
#include "tst_qdeclarativeloader.moc"