diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-05-11 15:37:37 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-05-13 09:50:10 (GMT) |
commit | 55829ebc5664a65fcef158e7ccd3579aaffa8d20 (patch) | |
tree | 4835e1e2be4937fa529ae6d6c5c78b699b3cebd2 | |
parent | 03415f5db33ee1d8af15b924f84b547a9ed8020b (diff) | |
download | Qt-55829ebc5664a65fcef158e7ccd3579aaffa8d20.zip Qt-55829ebc5664a65fcef158e7ccd3579aaffa8d20.tar.gz Qt-55829ebc5664a65fcef158e7ccd3579aaffa8d20.tar.bz2 |
Reset the 'connectedToScene' flag when changing the scene of a view
In QGraphicsScene::_q_emitUpdated() the slot
QGrpahicsView::updateScene(QList<QRectF>) gets connected and a boolean
(connectedToScene) is set to prevent double connections. The problem is
that this boolean was not reset when the view gets a new scene.
Task-number: 253415
Reviewed-by: andreas
-rw-r--r-- | src/gui/graphicsview/qgraphicsview.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 05e4907..8b133f3 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -1681,6 +1681,7 @@ void QGraphicsView::setScene(QGraphicsScene *scene) disconnect(d->scene, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(updateSceneRect(QRectF))); d->scene->d_func()->views.removeAll(this); + d->connectedToScene = false; } // Assign the new scene and update the contents (scrollbars, etc.)). diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index b5af115..db1e4c3 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -200,6 +200,7 @@ private slots: void task239729_noViewUpdate(); void task239047_fitInViewSmallViewport(); void task245469_itemsAtPointWithClip(); + void task253415_reconnectUpdateSceneOnSceneChanged(); }; void tst_QGraphicsView::initTestCase() @@ -3044,5 +3045,28 @@ void tst_QGraphicsView::centerOnDirtyItem() QCOMPARE(before, after); } +void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() +{ + QGraphicsView view; + QGraphicsView dummyView; + view.setWindowFlags(view.windowFlags() | Qt::WindowStaysOnTopHint); + view.resize(200, 200); + + QGraphicsScene scene1; + QObject::connect(&scene1, SIGNAL(changed(QList<QRectF>)), &dummyView, SLOT(updateScene(QList<QRectF>))); + view.setScene(&scene1); + + QTest::qWait(125); + + QGraphicsScene scene2; + QObject::connect(&scene2, SIGNAL(changed(QList<QRectF>)), &dummyView, SLOT(updateScene(QList<QRectF>))); + view.setScene(&scene2); + + QTest::qWait(125); + + bool wasConnected2 = QObject::disconnect(&scene2, SIGNAL(changed(QList<QRectF>)), &view, 0); + QVERIFY(wasConnected2); +} + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" |