summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp')
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 3564800a8b..4f1615a48e 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -66,6 +66,7 @@ private slots:
void setStyleShouldChangeSpacing();
void taskQTBUG_7103_minMaxWidthNotRespected();
+ void taskQTBUG_27420_takeAtShouldUnparentLayout();
};
class CustomLayoutStyle : public QProxyStyle
@@ -273,5 +274,26 @@ void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
QCOMPARE(label->height(), height);
}
+void tst_QBoxLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
+{
+ QSharedPointer<QHBoxLayout> outer(new QHBoxLayout);
+ QPointer<QVBoxLayout> inner = new QVBoxLayout;
+
+ outer->addLayout(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_QBoxLayout)
#include "tst_qboxlayout.moc"