Patch #2879 2009-12-27 19:10

techy

Call SetProject() only after workspace is opened (debug7)
Download
2879-Call_SetProjec.patch (1.3 KB)
Category
Application::Bugfix
Status
Accepted
Close date
2010-08-19 07:01
Assigned to
mortenmacfly
Index: src/sdk/projectmanager.cpp
===================================================================
--- src/sdk/projectmanager.cpp    (revision 5986)
+++ src/sdk/projectmanager.cpp    (working copy)
@@ -856,7 +856,19 @@
 
     EndLoadingProject(result);
     if (activateIt)
-        SetProject(result, !m_IsLoadingWorkspace);
+    {
+        if (m_IsLoadingWorkspace)
+        {
+            // postpone call of SetProject() until EndLoadingWorkspace() is called
+            // (we must call RebuildTree() before SetProject() is called)
+            m_pActiveProject = result;
+        }
+        else
+        {
+            SetProject(result, true);            
+        }
+    }
+    
     return result;
 }
 
@@ -1684,7 +1696,12 @@
             continue;
         }
 
-        arr->Remove(base);
+        int index = arr->Index(base);
+        if (index != wxNOT_FOUND)
+        {
+            arr->RemoveAt(index);
+        }
+        
         if (m_pWorkspace)
             m_pWorkspace->SetModified(true);
 
@@ -2865,7 +2882,10 @@
     {
         RebuildTree();
         if (m_pActiveProject)
+        {
+            SetProject(m_pActiveProject, true);
             m_pTree->Expand(m_pActiveProject->GetProjectNode());
+        }
         m_pTree->Expand(m_TreeRoot); // make sure the root node is open
         m_pTree->SetItemText(m_TreeRoot, m_pWorkspace->GetTitle());
 
techy 2009-12-27 19:18

When loading workspace, RebuildTree() is called only after the whole workspace is loaded. This means that in this case we cannot call m_pActiveProject->GetProjectNode() because the project node doesn't exist yet. This is however what SetProject() does so in this case SetProject() should be called only after the whole workspace is loaded.