src/gui/widgets/qdockarealayout.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
--- a/src/gui/widgets/qdockarealayout.cpp	Fri Apr 16 15:50:13 2010 +0300
+++ b/src/gui/widgets/qdockarealayout.cpp	Mon May 03 13:17:34 2010 +0300
@@ -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;
         }