diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2013-04-23 13:04:26 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-25 12:51:42 (GMT) |
commit | c0688f4117304b4828796aa9489ca2c0d50c9886 (patch) | |
tree | e361146557931854c8e8d46a2e2f2cfffcc54dff /tests/auto/qboxlayout | |
parent | 17f263905f00dfd0f01d9f5226ac06b07aa9d421 (diff) | |
download | Qt-c0688f4117304b4828796aa9489ca2c0d50c9886.zip Qt-c0688f4117304b4828796aa9489ca2c0d50c9886.tar.gz Qt-c0688f4117304b4828796aa9489ca2c0d50c9886.tar.bz2 |
Fixed QLayout::addChildLayout(QLayout *l) when l had a parent
Previously if l had a parent, addChildLayout would warn and skip the
reparenting, but it would still add the sub layout to the layout.
This caused some inconsistencies in the hierarchy which in worst case
could cause crashes.
Task-number: QTBUG-30758
(cherry-picked from qtbase commit 146658a10f290603470b800d71b778239e764312)
Change-Id: Iee6ace3189620395d7670007a23783823ed616b9
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'tests/auto/qboxlayout')
-rw-r--r-- | tests/auto/qboxlayout/tst_qboxlayout.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qboxlayout/tst_qboxlayout.cpp b/tests/auto/qboxlayout/tst_qboxlayout.cpp index 0f9bbce..466be31 100644 --- a/tests/auto/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/qboxlayout/tst_qboxlayout.cpp @@ -62,6 +62,7 @@ public slots: private slots: void insertSpacerItem(); + void insertLayout(); void sizeHint(); void sizeConstraints(); void setGeometry(); @@ -160,6 +161,26 @@ void tst_QBoxLayout::insertSpacerItem() window->show(); } +void tst_QBoxLayout::insertLayout() +{ + QWidget *window = new QWidget; + QVBoxLayout *vbox = new QVBoxLayout(window); + QVBoxLayout *dummyParentLayout = new QVBoxLayout; + QHBoxLayout *subLayout = new QHBoxLayout; + dummyParentLayout->addLayout(subLayout); + QCOMPARE(subLayout->parent(), dummyParentLayout); + QCOMPARE(dummyParentLayout->count(), 1); + + // add subLayout to another layout + QTest::ignoreMessage(QtWarningMsg, "QLayout::addChildLayout: layout \"\" already has a parent"); + vbox->addLayout(subLayout); + QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1)); + + delete dummyParentLayout; + delete window; +} + + void tst_QBoxLayout::sizeHint() { QWidget *window = new QWidget; |