summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qformlayout
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel/qformlayout')
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 3aa0ea03f4..b2cdb87221 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -51,6 +51,7 @@
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton>
#include <QStyleFactory>
+#include <QSharedPointer>
#include <qformlayout.h>
@@ -123,6 +124,8 @@ private slots:
Qt::Orientations expandingDirections() const;
*/
+ void taskQTBUG_27420_takeAtShouldUnparentLayout();
+
};
tst_QFormLayout::tst_QFormLayout()
@@ -901,6 +904,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.reset();
+
+ 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"