diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-03-08 07:17:15 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-03-08 07:17:15 (GMT) |
commit | 9b06c2dd119f3c4442f7b26756728bb9c7fefb4a (patch) | |
tree | 8f02caf1d949a8159a985515435fd1159c0792ac | |
parent | 4d8214afabd5e093c02b0de0e72f24139af6660f (diff) | |
download | Qt-9b06c2dd119f3c4442f7b26756728bb9c7fefb4a.zip Qt-9b06c2dd119f3c4442f7b26756728bb9c7fefb4a.tar.gz Qt-9b06c2dd119f3c4442f7b26756728bb9c7fefb4a.tar.bz2 |
clearFocus() before setParentItem(0) on an item with focus.
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 55f1c89..6bad4da 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -927,6 +927,8 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q if (inPackage) { emit destroyingPackage(qobject_cast<QDeclarativePackage*>(obj)); } else { + if (item->hasFocus()) + item->clearFocus(); item->setOpacity(0.0); static_cast<QGraphicsItem*>(item)->setParentItem(0); } diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 7ade309..aeefea1 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -659,9 +659,14 @@ void tst_QDeclarativeGridView::currentIndex() QCOMPARE(gridview->contentY(), 0.0); // Test keys - qApp->setActiveWindow(canvas); canvas->show(); - canvas->setFocus(); + qApp->setActiveWindow(canvas); +#ifdef Q_WS_X11 + // to be safe and avoid failing setFocus with window managers + qt_x11_wait_for_window_manager(canvas); +#endif + QVERIFY(canvas->hasFocus()); + QVERIFY(canvas->scene()->hasFocus()); qApp->processEvents(); QTest::keyClick(canvas, Qt::Key_Down); @@ -672,7 +677,6 @@ void tst_QDeclarativeGridView::currentIndex() gridview->setFlow(QDeclarativeGridView::TopToBottom); - QEXPECT_FAIL("", "QTBUG-8475", Abort); QTest::keyClick(canvas, Qt::Key_Right); QCOMPARE(gridview->currentIndex(), 5); |