src/gui/widgets/qdockarealayout.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
--- a/src/gui/widgets/qdockarealayout.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/src/gui/widgets/qdockarealayout.cpp	Wed Mar 31 11:06:36 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -1990,16 +1990,19 @@
 #ifdef QT_NO_TABBAR
             const int tabBarShape = 0;
 #endif
-            QDockAreaLayoutInfo *info = new QDockAreaLayoutInfo(sep, dockPos, o,
-                                                                tabBarShape, mainWindow);
-            QDockAreaLayoutItem item(info);
+            QDockAreaLayoutItem item(new QDockAreaLayoutInfo(sep, dockPos, o,
+                                                                tabBarShape, mainWindow));
             stream >> item.pos >> item.size >> dummy >> dummy;
-            if (!info->restoreState(stream, widgets, testing))
+            //we need to make sure the element is in the list so the dock widget can eventually be docked correctly
+            if (!testing)
+                item_list.append(item);
+            
+            //here we need to make sure we change the item in the item_list
+            QDockAreaLayoutItem &lastItem = testing ? item : item_list.last();
+
+            if (!lastItem.subinfo->restoreState(stream, widgets, testing))
                 return false;
 
-            if (!testing) {
-                item_list.append(item);
-            }
         } else {
             return false;
         }
@@ -2635,7 +2638,7 @@
     QSize bottom_max = docks[QInternal::BottomDock].maximumSize();
     bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);
 
-    fallbackToSizeHints = !have_central;
+    fallbackToSizeHints = false;
 
     if (_ver_struct_list != 0) {
         QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list;