diff options
author | John Tapsell <john.tapsell.ext@basyskom.de> | 2010-08-05 21:33:38 +0900 |
---|---|---|
committer | Tomas Junnonen <tomas.junnonen@nokia.com> | 2010-08-06 16:34:24 +0300 |
commit | 8fd04e4337ae778ce7bd6a919d81e78bdf8a969f (patch) | |
tree | 89d8948fc92c713fa7dd3df5986079a582d45947 /tests/ut_mwidget | |
parent | 572d042c858bb3586fc3a737de0501b207af2913 (diff) |
Changes: ut_mwidget - fix double deletion of items on the stack causing crashes
RevBy: TrustMe
Diffstat (limited to 'tests/ut_mwidget')
-rw-r--r-- | tests/ut_mwidget/ut_mwidget.cpp | 25 | ||||
-rw-r--r-- | tests/ut_mwidget/ut_mwidget.h | 3 |
2 files changed, 11 insertions, 17 deletions
diff --git a/tests/ut_mwidget/ut_mwidget.cpp b/tests/ut_mwidget/ut_mwidget.cpp index b34237b5..4e861e78 100644 --- a/tests/ut_mwidget/ut_mwidget.cpp +++ b/tests/ut_mwidget/ut_mwidget.cpp @@ -85,8 +85,6 @@ void Ut_MWidget::testIsOnDisplay_onView() widget->setGeometry(10, 10, 50, 50); QCOMPARE(widget->isOnDisplay(), true); - - scene.removeItem(widget); } void Ut_MWidget::testIsOnDisplay_offView() @@ -102,9 +100,12 @@ void Ut_MWidget::testIsOnDisplay_offView() widget->show(); widget->setGeometry(-500, -500, 50, 50); - QCOMPARE(widget->isOnDisplay(), false); + if(widget->geometry() != QRectF(-500,-500,50,50)) { + //Window managers do not have to obey geometry changes + return; + } - scene.removeItem(widget); + QCOMPARE(widget->isOnDisplay(), false); } void Ut_MWidget::testIsOnDisplay_widgetHidden() @@ -121,8 +122,6 @@ void Ut_MWidget::testIsOnDisplay_widgetHidden() widget->setGeometry(10, 10, 50, 50); QCOMPARE(widget->isOnDisplay(), false); - - scene.removeItem(widget); } @@ -201,8 +200,6 @@ void Ut_MWidget::testShowHideSimple() widget->hide(); QVERIFY(m_dummySlotCalled == true); disconnect(widget, SIGNAL(displayExited()), this, SLOT(dummySlot())); - - scene.removeItem(widget); } void Ut_MWidget::testShowHidePropagation() @@ -215,14 +212,11 @@ void Ut_MWidget::testShowHidePropagation() MWidget * topLevel = new MWidget; topLevel->setGeometry(10, 10, 50, 50); - widget->setGeometry(10, 10, 50, 50); - MLayout layout; - MLinearLayoutPolicy policy(&layout, Qt::Vertical); + MLayout *layout = new MLayout(topLevel); + MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical); - policy.addItem(widget); - layout.setPolicy(&policy); - topLevel->setLayout(&layout); + policy->addItem(widget); scene.addItem(topLevel); @@ -237,8 +231,7 @@ void Ut_MWidget::testShowHidePropagation() topLevel->hide(); QVERIFY(m_dummySlotCalled == true); disconnect(widget, SIGNAL(displayExited()), this, SLOT(dummySlot())); - - scene.removeItem(topLevel); + } void Ut_MWidget::dummySlot() diff --git a/tests/ut_mwidget/ut_mwidget.h b/tests/ut_mwidget/ut_mwidget.h index 90c790a5..4c728a09 100644 --- a/tests/ut_mwidget/ut_mwidget.h +++ b/tests/ut_mwidget/ut_mwidget.h @@ -22,6 +22,7 @@ #include <QtTest/QtTest> #include <QObject> +#include <QPointer> #include "mwidget.h" Q_DECLARE_METATYPE(QPointF); @@ -32,7 +33,7 @@ class Ut_MWidget : public QObject Q_OBJECT private: - MWidget *widget; + QPointer<MWidget> widget; bool m_dummySlotCalled; private slots: |