diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-05-01 18:31:54 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-05-05 05:02:51 +0000 |
commit | 3287e7a68a3feff5c34f109b6af0f894a0362801 (patch) | |
tree | 462e934f342e135e68833aab3cb4d1e280f6d2e9 /tests/auto/widgets | |
parent | f44f2136e07bfea792a7aafd7c2058eac0ba595d (diff) |
QGraphicsWidget: call normal "setParent" when setting a parent
QGraphicsWidgetPrivate::init had a special code path for setting
the item's parent. For some reason that code path caused the
ItemChildAddedChange notification not to be sent to the parent
element, which is wrong. Instead use the "normal" path, which is
what the QGraphicsItem constructor does anyhow.
Change-Id: Iad84cae05d797022a45977d35ca00c80c17c306a
Task-number: QTBUG-45867
Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index da0c5532a5..9b92c34fb5 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -179,6 +179,7 @@ private slots: void task250119_shortcutContext(); void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems(); void QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems(); + void QTBUG_45867_send_itemChildAddedChange_to_parent(); }; @@ -3490,5 +3491,36 @@ void tst_QGraphicsWidget::QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems() //This should not crash } +void tst_QGraphicsWidget::QTBUG_45867_send_itemChildAddedChange_to_parent() +{ + class GraphicsItem : public QGraphicsItem + { + public: + int m_itemChildAddedChangeNotificationsCount; + + GraphicsItem() + : QGraphicsItem(), + m_itemChildAddedChangeNotificationsCount(0) + { + } + + QRectF boundingRect() const Q_DECL_OVERRIDE { return QRectF(); } + + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) Q_DECL_OVERRIDE {} + + protected: + QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE + { + if (change == QGraphicsItem::ItemChildAddedChange) + ++m_itemChildAddedChangeNotificationsCount; + return QGraphicsItem::itemChange(change, value); + } + }; + + GraphicsItem item; + QGraphicsWidget widget(&item); + QCOMPARE(item.m_itemChildAddedChangeNotificationsCount, 1); +} + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" |