summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-10-21 20:10:22 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-02 00:23:14 +0100
commit716d33d2a73ade42eb31be3e8ecbaeecdd5ddd21 (patch)
treef5e97e43c917bf64ec456aa86d32a4e91edbe3b3 /tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
parent1211b956de5ef63cfe65e9cb0c49a42d52c0a3d9 (diff)
[QTBUG-27420] Make Q{Box,Grid,Form}Layout::takeAt() unparent a nested layout
QStackedLayout doesn't have support for QLayout, only QWidget, so the issue doesn't arise there. Reported-by: Johannes Schaub Task-number: QTBUG-27420 Change-Id: I71f8d10a036918c16d8f8c9197a2ec61cd76cf01 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp')
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 34b38c1e53..e52ff3fa8b 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -52,6 +52,7 @@
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QRadioButton>
#include <QStyleFactory>
+#include <QSharedPointer>
class tst_QGridLayout : public QObject
{
@@ -89,6 +90,8 @@ private slots:
void contentsRect();
void distributeMultiCell();
+ void taskQTBUG_27420_takeAtShouldUnparentLayout();
+
private:
QWidget *testWidget;
QGridLayout *testLayout;
@@ -1605,5 +1608,26 @@ void tst_QGridLayout::distributeMultiCell()
QCOMPARE(w.sizeHint().height(), 11 + 57 + 11);
}
+void tst_QGridLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
+{
+ QSharedPointer<QGridLayout> outer(new QGridLayout);
+ QPointer<QGridLayout> inner = new QGridLayout;
+
+ outer->addLayout(inner, 0, 0);
+ 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_QGridLayout)
#include "tst_qgridlayout.moc"