From 162071d2651645358a0935b27af8a3b47474a10f Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Tue, 17 Nov 2009 17:17:16 +0100 Subject: Fixes polish events for explicitly hidden GraphicsWidgetItems. The problem was that hidden items never get added to "unpolishedItems" list and thus never get the polish event. Autotest included. Task-number: QTBUG-3939 Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsscene.cpp | 8 +++----- tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 24 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 5b0643d..a463c01 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2556,11 +2556,9 @@ void QGraphicsScene::addItem(QGraphicsItem *item) item->d_ptr->resolveFont(d->font.resolve()); item->d_ptr->resolvePalette(d->palette.resolve()); - if (!item->d_ptr->explicitlyHidden) { - if (d->unpolishedItems.isEmpty()) - QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); - d->unpolishedItems.insert(item); - } + if (d->unpolishedItems.isEmpty()) + QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); + d->unpolishedItems.insert(item); // Reenable selectionChanged() for individual items --d->selectionChanging; diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 829e55c..3b98c2f 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -161,6 +161,7 @@ private slots: void respectHFW(); void addChildInpolishEvent(); void polishEvent(); + void polishEvent2(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2796,6 +2797,29 @@ void tst_QGraphicsWidget::polishEvent() QCOMPARE(widget->events.at(0), QEvent::Polish); } +void tst_QGraphicsWidget::polishEvent2() +{ + class MyGraphicsWidget : public QGraphicsWidget + { public: + void polishEvent() + { events << QEvent::Polish; } + QList events; + }; + + QGraphicsScene scene; + + MyGraphicsWidget *widget = new MyGraphicsWidget; + widget->hide(); + scene.addItem(widget); + + widget->events.clear(); + + QApplication::processEvents(); + + // Make sure the item got polish event. + QVERIFY(widget->events.contains(QEvent::Polish)); +} + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" -- cgit v0.12