summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qlayout.cpp
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@theqtcompany.com>2015-03-13 14:49:51 +0100
committerJan Arve Sæther <jan-arve.saether@theqtcompany.com>2015-03-26 09:26:41 +0000
commitd59638f21d7ea7c2a7f5c57b3eca27da984a1917 (patch)
tree6e257baf7bd2393b905e6e41bf1fdcc0d1928f42 /src/widgets/kernel/qlayout.cpp
parent7dd5726380f5d5422edd4b71c6beba6d02b4e3df (diff)
Fixed bug in QLayout::replaceWidget()
If the \a to widget was already part of a layout it would be removed from the layout. This happened because the function that was supposed to perform this removal was called after we had done the replacement. QLayout::addChildWidget() should therefore be called first. This is also documented in QLayout::addChildWidget() Change-Id: Ie718935a14ebad81827fad962920e930263c05b8 Task-number: QTBUG-37724 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'src/widgets/kernel/qlayout.cpp')
-rw-r--r--src/widgets/kernel/qlayout.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 822690942e..dcacea4777 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1175,13 +1175,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt
if (index == -1)
return 0;
+ addChildWidget(to);
QLayoutItem *newitem = new QWidgetItem(to);
newitem->setAlignment(item->alignment());
QLayoutItem *r = d->replaceAt(index, newitem);
if (!r)
delete newitem;
- else
- addChildWidget(to);
return r;
}