summaryrefslogtreecommitdiffstats
path: root/src
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 /src
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 'src')
-rw-r--r--src/widgets/kernel/qboxlayout.cpp6
-rw-r--r--src/widgets/kernel/qformlayout.cpp7
-rw-r--r--src/widgets/kernel/qgridlayout.cpp15
3 files changed, 23 insertions, 5 deletions
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index d16c999508..62c4e526c7 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -729,6 +729,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/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index b726ff83f8..f875de16df 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -1409,6 +1409,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/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index b5cd746c03..eda9b9def6 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/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) const {