diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2011-01-07 13:29:38 (GMT) |
---|---|---|
committer | Yoann Lopes <yoann.lopes@nokia.com> | 2011-01-07 13:29:38 (GMT) |
commit | 8ffb49a4ac68b1c243b25343053e6e99f97ec2e7 (patch) | |
tree | 9d50f23c3c614e358bdd903a54970701bf851e23 /tests | |
parent | 67267842ce658d956f11d52194566b6de1f84f9a (diff) | |
download | Qt-8ffb49a4ac68b1c243b25343053e6e99f97ec2e7.zip Qt-8ffb49a4ac68b1c243b25343053e6e99f97ec2e7.tar.gz Qt-8ffb49a4ac68b1c243b25343053e6e99f97ec2e7.tar.bz2 |
Fixes crash in QGraphicsItem's destructor.
Crash introduced by 783a278f243c6411f5f32d11f2165b9eed9b6f8c.
Autotest written by Niklas Kurkisuo <ext-niklas.kurkisuo@nokia.com>
Task-number: QTBUG-16374
Reviewed-by: TrustMe
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 0b29410..5daafd8 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -65,6 +65,7 @@ #include <QInputContext> #include <QPushButton> #include <QLineEdit> +#include <QGraphicsLinearLayout> #include "../../shared/util.h" @@ -469,6 +470,7 @@ private slots: void itemDiesDuringDraggingOperation(); void QTBUG_12112_focusItem(); void QTBUG_13473_sceneposchange(); + void QTBUG_16374_crashInDestructor(); private: QList<QGraphicsItem *> paintedItems; @@ -11077,5 +11079,56 @@ void tst_QGraphicsItem::QTBUG_13473_sceneposchange() QCOMPARE(child->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 2); } +class MyGraphicsWidget : public QGraphicsWidget { +Q_OBJECT +public: + MyGraphicsWidget() + : QGraphicsWidget(0) + { + QGraphicsLinearLayout *lay = new QGraphicsLinearLayout(Qt::Vertical); + QLatin1String wiseWords("AZ BUKI VEDI"); + QString sentence(wiseWords); + QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts); + for (int i = 0; i < words.count(); ++i) { + QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); + QLabel *label = new QLabel(words.at(i)); + proxy->setWidget(label); + proxy->setFocusPolicy(Qt::StrongFocus); + proxy->setFlag(QGraphicsItem::ItemAcceptsInputMethod, true); + if (i%2 == 0) + proxy->setVisible(false); + proxy->setFocus(); + lay->addItem(proxy); + } + setLayout(lay); + } + +}; + +class MyWidgetWindow : public QGraphicsWidget +{ +public: + MyWidgetWindow() + : QGraphicsWidget(0, Qt::Window) + { + QGraphicsLinearLayout *lay = new QGraphicsLinearLayout(Qt::Vertical); + MyGraphicsWidget *widget = new MyGraphicsWidget(); + lay->addItem(widget); + setLayout(lay); + } +}; + +void tst_QGraphicsItem::QTBUG_16374_crashInDestructor() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + MyWidgetWindow win; + scene.addItem(&win); + + view.show(); + QTest::qWaitForWindowShown(&view); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" |