Commit d59638f2 authored by Jan Arve Saether's avatar Jan Arve Saether Committed by Jan Arve Sæther
Browse files

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: default avatarThorbjørn Lund Martsum <tmartsum@gmail.com>
parent 7dd57263
Branches
Tags
No related merge requests found
Showing with 1 addition and 2 deletions
...@@ -1175,13 +1175,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt ...@@ -1175,13 +1175,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt
if (index == -1) if (index == -1)
return 0; return 0;
addChildWidget(to);
QLayoutItem *newitem = new QWidgetItem(to); QLayoutItem *newitem = new QWidgetItem(to);
newitem->setAlignment(item->alignment()); newitem->setAlignment(item->alignment());
QLayoutItem *r = d->replaceAt(index, newitem); QLayoutItem *r = d->replaceAt(index, newitem);
if (!r) if (!r)
delete newitem; delete newitem;
else
addChildWidget(to);
return r; return r;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment