summaryrefslogtreecommitdiffstats
path: root/tests/auto/qformlayout/tst_qformlayout.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-10-21 18:10:22 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-09 13:48:18 (GMT)
commit7f6155a9c1361355d3c9e88a1a8d1a6415857ebc (patch)
tree4db298129164b4a46eaf1606f7e08f126e0c2f72 /tests/auto/qformlayout/tst_qformlayout.cpp
parent63097b8ab370607b5952d4278609776b0b150634 (diff)
downloadQt-7f6155a9c1361355d3c9e88a1a8d1a6415857ebc.zip
Qt-7f6155a9c1361355d3c9e88a1a8d1a6415857ebc.tar.gz
Qt-7f6155a9c1361355d3c9e88a1a8d1a6415857ebc.tar.bz2
[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. (cherry-picked from qtbase/716d33d2a73ade42eb31be3e8ecbaeecdd5ddd21) (only change: s/reset()/clear()/ in the tests) Reported-by: Johannes Schaub Task-number: QTBUG-27420 Change-Id: I7f3c4b1996e954428c00d4dda1095712efa91367 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'tests/auto/qformlayout/tst_qformlayout.cpp')
-rw-r--r--tests/auto/qformlayout/tst_qformlayout.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qformlayout/tst_qformlayout.cpp b/tests/auto/qformlayout/tst_qformlayout.cpp
index 89c8f99..462992c 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"