summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-04-30 10:35:06 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-08 06:47:29 +0200
commit01bc34088eb8e7fb4842fa1c2117cddbac086136 (patch)
tree60153a770c9e50faa04afd3cb23073f1f5f5d776 /tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
parentbf2a0c795ed3a9c14e6cbbabc4456f3e9ebf7d6d (diff)
Fix tabFocusFirst when that item is removed from QGraphicsScene
If tabFocusFirst is not cleared or set to another valid item, there will be crash later if the removed item is deleted after removal. Task-number: QTBUG-30923 Change-Id: Iba9a6ce9334c52f8e552b0accda95ebb5fcfcdb1 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
index 08a10aa593..2bb588afed 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -1696,6 +1696,24 @@ void tst_QGraphicsWidget::verifyFocusChain()
delete w;
}
{
+ // QTBUG-30923:
+ // Child QGraphicsWidget with tabFocusFirst gets removed & deleted should not crash.
+ // This case simulates what QtQuick1 does when you have QGraphicsObject based
+ // item in different qml views that are loaded one after another.
+ QGraphicsItem *parent1 = new QGraphicsRectItem(0); // root item
+ scene.addItem(parent1);
+ for (int i = 0; i < 2; i++) {
+ SubQGraphicsWidget *w1 = new SubQGraphicsWidget(parent1);
+ w1->setFocusPolicy(Qt::StrongFocus);
+ w1->setFocus();
+ QVERIFY(w1->hasFocus());
+ scene.removeItem(w1);
+ delete w1;
+ QApplication::processEvents();
+ }
+ delete parent1;
+ }
+ {
// remove the tabFocusFirst widget from the scene.
QWidget *window = new QWidget;
QVBoxLayout *layout = new QVBoxLayout;