Prevent a crash in QLayout::replaceWidget

Item might be null.

Change-Id: Ia432a35cb1a6bb02ee056ff8ad44a9f35bdbc146
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Giuseppe D'Angelo 2013-11-08 13:03:22 +01:00 committed by The Qt Project
parent c934ea341e
commit 2d1bb6d61d

View File

@ -1133,11 +1133,15 @@ QLayoutItem* QLayout::replaceWidget(QWidget *from, QWidget *to, bool recursive)
QLayoutItem *item = 0;
for (int u = 0; u < count(); ++u) {
item = itemAt(u);
if (!item)
continue;
if (item->widget() == from) {
index = u;
break;
}
if (item && item->layout() && recursive) {
if (item->layout() && recursive) {
QLayoutItem *r = item->layout()->replaceWidget(from, to, true);
if (r)
return r;