diff options
Diffstat (limited to 'tests/auto/qformlayout/tst_qformlayout.cpp')
-rw-r--r-- | tests/auto/qformlayout/tst_qformlayout.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qformlayout/tst_qformlayout.cpp b/tests/auto/qformlayout/tst_qformlayout.cpp index 89c8f999fa..462992cf51 100644 --- a/tests/auto/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/qformlayout/tst_qformlayout.cpp @@ -50,6 +50,7 @@ #include <QtGui/QWindowsStyle> #include <QStyleFactory> +#include <QSharedPointer> #include <qformlayout.h> @@ -125,6 +126,8 @@ private slots: Qt::Orientations expandingDirections() const; */ + void taskQTBUG_27420_takeAtShouldUnparentLayout(); + }; tst_QFormLayout::tst_QFormLayout() @@ -905,6 +908,27 @@ void tst_QFormLayout::layoutAlone() QTest::qWait(500); } +void tst_QFormLayout::taskQTBUG_27420_takeAtShouldUnparentLayout() +{ + QSharedPointer<QFormLayout> outer(new QFormLayout); + QPointer<QFormLayout> inner = new QFormLayout; + + outer->addRow(inner); + QCOMPARE(outer->count(), 1); + QCOMPARE(inner->parent(), outer.data()); + + QLayoutItem *item = outer->takeAt(0); + QCOMPARE(item->layout(), inner.data()); + QVERIFY(!item->layout()->parent()); + + outer.clear(); + + if (inner) + delete item; // success: a taken item/layout should not be deleted when the old parent is deleted + else + QVERIFY(!inner.isNull()); +} + QTEST_MAIN(tst_QFormLayout) #include "tst_qformlayout.moc" |