CFrameWnd:: SetDockState
Hi
I'm in the process of updating a project from VS2003 to VS2008. After
finally getting the project to build/link its crashes on start up. After some
investigation I narrowed the problem down to the following function
CFrameWnd:: SetDockState.
VS2008 Version of CFrameWnd:: SetDockState
else // regular dock bar or toolbar in the loading state
{
pInfo->m_pBar = GetControlBar(pInfo->m_nBarID);
ASSERT(pInfo->m_pBar != NULL); //toolbar id's probably changed
if ((pInfo->m_pBar->m_pDockBar != NULL) &&
(pInfo->m_pBar->m_pDockBar->m_bFloating)) // control is floating in
the current state
{
// need to dock the control bar
DockControlBar (pInfo->m_pBar);
}
}
Should the code not check to make sure pInfo_m_pBar != NULL before
attempting to access pInfo->m_pBar->m_pDockBar? It certainly seems to for the
rest of the code in the function
e.g.
// the second pass will actually dock all of the control bars and
// set everything correctly
for (i = 0; i < state.m_arrBarInfo.GetSize(); i++)
{
CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo;
ASSERT(pInfo != NULL);
if (pInfo->m_pBar != NULL)
pInfo->m_pBar->SetBarInfo(pInfo, this);
}
This is not a problem for the VS2003 version as it never accesses m_pDockBar.
VS2003 Version of CFrameWnd:: SetDockState
else // regular dock bar or toolbar
{
pInfo->m_pBar = GetControlBar(pInfo->m_nBarID);
ASSERT(pInfo->m_pBar != NULL); //toolbar id's probably changed
}
Any thoughts?
Regards
Richard