From f1344a817fdb3d263bd64f4440fedc73ad94ad31 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 4 Nov 2010 13:00:50 +1000 Subject: Don't emit xChanged()/yChanged() twice. Once from QGraphicsObject (QGraphicsItemPrivate::setPosHelper()) and once from QDeclarativeItem::geometryChanged(). Remove from geometryChanged(). Task-number: QTBUG-14942 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 4 ---- .../auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 95a4fd6..e0df751 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1955,12 +1955,8 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry, change.listener->itemGeometryChanged(this, newGeometry, oldGeometry); } - if (newGeometry.x() != oldGeometry.x()) - emit xChanged(); if (newGeometry.width() != oldGeometry.width()) emit widthChanged(); - if (newGeometry.y() != oldGeometry.y()) - emit yChanged(); if (newGeometry.height() != oldGeometry.height()) emit heightChanged(); } diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index b4903ae..711bf00 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -686,6 +686,8 @@ void tst_QDeclarativeItem::propertyChanges() QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool))); QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged())); + QSignalSpy xSpy(item, SIGNAL(xChanged())); + QSignalSpy ySpy(item, SIGNAL(yChanged())); item->setParentItem(parentItem); item->setWidth(100.0); @@ -731,6 +733,14 @@ void tst_QDeclarativeItem::propertyChanges() QCOMPARE(parentItem->hasFocus(), false); QCOMPARE(wantsFocusSpy.count(),0); + item->setX(10.0); + QCOMPARE(item->x(), 10.0); + QCOMPARE(xSpy.count(), 1); + + item->setY(10.0); + QCOMPARE(item->y(), 10.0); + QCOMPARE(ySpy.count(), 1); + delete canvas; } -- cgit v0.12