diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-10-21 18:10:22 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-09 13:48:18 (GMT) |
commit | 7f6155a9c1361355d3c9e88a1a8d1a6415857ebc (patch) | |
tree | 4db298129164b4a46eaf1606f7e08f126e0c2f72 /src | |
parent | 63097b8ab370607b5952d4278609776b0b150634 (diff) | |
download | Qt-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 'src')
-rw-r--r-- | src/gui/kernel/qboxlayout.cpp | 6 | ||||
-rw-r--r-- | src/gui/kernel/qformlayout.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qgridlayout.cpp | 15 |
3 files changed, 23 insertions, 5 deletions
diff --git a/src/gui/kernel/qboxlayout.cpp b/src/gui/kernel/qboxlayout.cpp index 5dde1d2..cca524d 100644 --- a/src/gui/kernel/qboxlayout.cpp +++ b/src/gui/kernel/qboxlayout.cpp @@ -788,6 +788,12 @@ QLayoutItem *QBoxLayout::takeAt(int index) b->item = 0; delete b; + if (QLayout *l = item->layout()) { + // sanity check in case the user passed something weird to QObject::setParent() + if (l->parent() == this) + l->setParent(0); + } + invalidate(); return item; } diff --git a/src/gui/kernel/qformlayout.cpp b/src/gui/kernel/qformlayout.cpp index 0cbb9fa..9e481ec 100644 --- a/src/gui/kernel/qformlayout.cpp +++ b/src/gui/kernel/qformlayout.cpp @@ -1410,6 +1410,13 @@ QLayoutItem *QFormLayout::takeAt(int index) QLayoutItem *i = item->item; item->item = 0; delete item; + + if (QLayout *l = i->layout()) { + // sanity check in case the user passed something weird to QObject::setParent() + if (l->parent() == this) + l->setParent(0); + } + return i; } diff --git a/src/gui/kernel/qgridlayout.cpp b/src/gui/kernel/qgridlayout.cpp index cb0dc90..3f11faa 100644 --- a/src/gui/kernel/qgridlayout.cpp +++ b/src/gui/kernel/qgridlayout.cpp @@ -156,15 +156,20 @@ public: return 0; } inline QLayoutItem *takeAt(int index) { - QLayoutItem *item = 0; + Q_Q(QGridLayout); if (index < things.count()) { - QGridBox *b = things.takeAt(index); - if (b) { - item = b->takeItem(); + if (QGridBox *b = things.takeAt(index)) { + QLayoutItem *item = b->takeItem(); + if (QLayout *l = item->layout()) { + // sanity check in case the user passed something weird to QObject::setParent() + if (l->parent() == q) + l->setParent(0); + } delete b; + return item; } } - return item; + return 0; } void getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) { |