Check if the widgetItem is valid before accessing widget() on it

If a state was restored but not all the dockwidgets that were available
before are available at the time of restoration then when dragging a
dockwidget to where the unavailable one is expected to be would cause a
crash.

Change-Id: I829d93041b7950a3546ba4e6c3764b169f276315
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Andy Shaw 2013-07-30 14:23:09 +02:00 committed by The Qt Project
parent e54ef7f23b
commit f29bbbde5f

View File

@ -1471,7 +1471,7 @@ QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const
continue;
}
if (!(item.flags & QDockAreaLayoutItem::GapItem) && item.widgetItem->widget() == widget) {
if (!(item.flags & QDockAreaLayoutItem::GapItem) && item.widgetItem && item.widgetItem->widget() == widget) {
QList<int> result;
result << i;
return result;