some first analysis (more to follow)
the offending line of code :
m_pTree->Expand(m_pActiveProject->GetProjectNode());
in ProjectManager::LoadWorkSpace
Why : the workspace only had 1 project, which was the active on, the loading of that project failed (see REMARK 1)), so the m_pActiveProject is still NULL -->crash
REMARK 1 : Where does the loading fail, or where does the system know there's a problem with the project
ProjectManager::LoadWorkSpace -> m_pWorkspace = new cbWorkspace(filename)
This leads us to : WorkspaceLoader::Open() which tries to open all projects mentioned in the workspace.
wxFileName fname(projectFilename);
fname.MakeAbsolute(wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
int active = 0;
int ret = proj->QueryIntAttribute("active", &active);
switch (ret)
{
case TIXML_SUCCESS:
if (active == 1)
GetpMan()->LoadProject(fname.GetFullPath(), true); // activate it
break;
case TIXML_WRONG_TYPE:
GetpMsg()->DebugLog(_("Error %s: %s"), doc.Value(), doc.ErrorDesc());
GetpMsg()->DebugLog(_("Wrong attribute type (expected 'int')"));
break;
default:
GetpMan()->LoadProject(fname.GetFullPath(), false); // don;t activate it
break;
In this case it's the TIXML_SUCCESS case with active == 1, and in the call to ProjectManager::LoadProject() it is discovered that the project can not be loaded, note the funtion will return NULL.
Since in the mentioned example, there are no other projects in the workspace, end of story and no m_pActiveProject.
Open Questions (for my further analysis) : what if there are more then 1 project in the workspace :
- a non active fails to load
- the active one fails to load, but others OK, m_pActiveProject still NULL ? if so make the next one active ??
It seems that in the example case, it is sure that there will never be an active project, --> offending line : if protect on m_pActiveProject != NULL.
Question : in such a case should we consider the workspace load to fail (since no project it contains was able to load) ?
.... to be continued
[EDIT 1] : just tested with 2 projects in workspace, with the 'active' one being failed, second one loads ok -> still no m_pActiveProject
[EDIT 2] : tested again with 2 projects in the workspace, but now the non-active going into failure, CodeBlocks error message box : Failed to create a temporary file name (error 267 : teh directory name is invalid), end result is the workspace is open with only the active project, second project : no sign of it.