Skip to content

Commit a678745

Browse files
committed
Move the EnsureValidDockState function to the CMergeFrameCommon class.
1 parent 27e1168 commit a678745

File tree

8 files changed

+33
-99
lines changed

8 files changed

+33
-99
lines changed

Src/ImgMergeFrm.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -585,38 +585,6 @@ int CImgMergeFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
585585
return 0;
586586
}
587587

588-
/**
589-
* @brief We must use this function before a call to SetDockState
590-
*
591-
* @note Without this, SetDockState will assert or crash if a bar from the
592-
* CDockState is missing in the current CMergeEditFrame.
593-
* The bars are identified with their ID. This means the missing bar bug is triggered
594-
* when we run WinMerge after changing the ID of a bar.
595-
*/
596-
bool CImgMergeFrame::EnsureValidDockState(CDockState& state)
597-
{
598-
for (int i = (int)state.m_arrBarInfo.GetSize() - 1; i >= 0; i--)
599-
{
600-
bool barIsCorrect = true;
601-
CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
602-
if (pInfo == nullptr)
603-
barIsCorrect = false;
604-
else
605-
{
606-
if (!pInfo->m_bFloating)
607-
{
608-
pInfo->m_pBar = GetControlBar(pInfo->m_nBarID);
609-
if (pInfo->m_pBar == nullptr)
610-
barIsCorrect = false; //toolbar id's probably changed
611-
}
612-
}
613-
614-
if (!barIsCorrect)
615-
state.m_arrBarInfo.RemoveAt(i);
616-
}
617-
return true;
618-
}
619-
620588
/**
621589
* @brief Save the window's position, free related resources, and destroy the window
622590
*/

Src/ImgMergeFrm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ class CImgMergeFrame : public CMergeFrameCommon,public IMergeDoc
9797

9898
// Implementation
9999
private:
100-
bool EnsureValidDockState(CDockState& state);
101100
void LoadOptions();
102101
void SaveOptions();
103102
void SavePosition();

Src/MergeEditFrm.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -231,38 +231,6 @@ BOOL CMergeEditFrame::OnBarCheck(UINT nID)
231231
return result;
232232
}
233233

234-
/**
235-
* @brief We must use this function before a call to SetDockState
236-
*
237-
* @note Without this, SetDockState will assert or crash if a bar from the
238-
* CDockState is missing in the current CMergeEditFrame.
239-
* The bars are identified with their ID. This means the missing bar bug is triggered
240-
* when we run WinMerge after changing the ID of a bar.
241-
*/
242-
bool CMergeEditFrame::EnsureValidDockState(CDockState& state)
243-
{
244-
for (int i = (int) state.m_arrBarInfo.GetSize()-1 ; i >= 0; i--)
245-
{
246-
bool barIsCorrect = true;
247-
CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
248-
if (pInfo == nullptr)
249-
barIsCorrect = false;
250-
else
251-
{
252-
if (! pInfo->m_bFloating)
253-
{
254-
pInfo->m_pBar = GetControlBar(pInfo->m_nBarID);
255-
if (pInfo->m_pBar == nullptr)
256-
barIsCorrect = false; //toolbar id's probably changed
257-
}
258-
}
259-
260-
if (! barIsCorrect)
261-
state.m_arrBarInfo.RemoveAt(i);
262-
}
263-
return true;
264-
}
265-
266234
void CMergeEditFrame::ActivateFrame(int nCmdShow)
267235
{
268236
CMergeFrameCommon::ActivateFrame(nCmdShow);

Src/MergeEditFrm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class CMergeEditFrame : public CMergeFrameCommon
6868

6969
// Implementation
7070
private:
71-
bool EnsureValidDockState(CDockState& state);
7271
void SavePosition();
7372
void SaveActivePane();
7473
virtual ~CMergeEditFrame();

Src/MergeFrameCommon.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,38 @@ std::pair<int, int> CMergeFrameCommon::MenuIDtoXY(UINT nID, int nActivePane, int
365365
return { srcPane, dstPane };
366366
}
367367

368+
/**
369+
* @brief We must use this function before a call to SetDockState
370+
*
371+
* @note Without this, SetDockState will assert or crash if a bar from the
372+
* CDockState is missing in the current CMergeEditFrame.
373+
* The bars are identified with their ID. This means the missing bar bug is triggered
374+
* when we run WinMerge after changing the ID of a bar.
375+
*/
376+
bool CMergeFrameCommon::EnsureValidDockState(CDockState& state)
377+
{
378+
for (int i = (int) state.m_arrBarInfo.GetSize()-1 ; i >= 0; i--)
379+
{
380+
bool barIsCorrect = true;
381+
CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
382+
if (pInfo == nullptr)
383+
barIsCorrect = false;
384+
else
385+
{
386+
if (! pInfo->m_bFloating)
387+
{
388+
pInfo->m_pBar = GetControlBar(pInfo->m_nBarID);
389+
if (pInfo->m_pBar == nullptr)
390+
barIsCorrect = false; //toolbar id's probably changed
391+
}
392+
}
393+
394+
if (! barIsCorrect)
395+
state.m_arrBarInfo.RemoveAt(i);
396+
}
397+
return true;
398+
}
399+
368400
void CMergeFrameCommon::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
369401
{
370402
__super::OnGetMinMaxInfo(lpMMI);

Src/MergeFrameCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CMergeFrameCommon: public CMDIChildWnd
2525
static String GetTooltipString(const PathContext& paths, const String desc[], const PackingInfo *pInfoUnpacker, const PrediffingInfo *pInfoPrediffer, bool hasTrivialDiffs = false);
2626
static void ChangeMergeMenuText(int srcPane, int dstPane, CCmdUI* pCmdUI);
2727
static std::pair<int, int> MenuIDtoXY(UINT nID, int nActivePane, int nBuffers);
28+
bool EnsureValidDockState(CDockState& state);
2829
void SaveWindowState();
2930
void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; }
3031
void RemoveBarBorder();

Src/WebPageDiffFrm.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -553,38 +553,6 @@ int CWebPageDiffFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
553553
return 0;
554554
}
555555

556-
/**
557-
* @brief We must use this function before a call to SetDockState
558-
*
559-
* @note Without this, SetDockState will assert or crash if a bar from the
560-
* CDockState is missing in the current CMergeEditFrame.
561-
* The bars are identified with their ID. This means the missing bar bug is triggered
562-
* when we run WinMerge after changing the ID of a bar.
563-
*/
564-
bool CWebPageDiffFrame::EnsureValidDockState(CDockState& state)
565-
{
566-
for (int i = (int)state.m_arrBarInfo.GetSize() - 1; i >= 0; i--)
567-
{
568-
bool barIsCorrect = true;
569-
CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
570-
if (pInfo == nullptr)
571-
barIsCorrect = false;
572-
else
573-
{
574-
if (!pInfo->m_bFloating)
575-
{
576-
pInfo->m_pBar = GetControlBar(pInfo->m_nBarID);
577-
if (pInfo->m_pBar == nullptr)
578-
barIsCorrect = false; //toolbar id's probably changed
579-
}
580-
}
581-
582-
if (!barIsCorrect)
583-
state.m_arrBarInfo.RemoveAt(i);
584-
}
585-
return true;
586-
}
587-
588556
/**
589557
* @brief Save the window's position, free related resources, and destroy the window
590558
*/

Src/WebPageDiffFrm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class CWebPageDiffFrame : public CMergeFrameCommon,public IMergeDoc
9090

9191
// Implementation
9292
private:
93-
bool EnsureValidDockState(CDockState& state);
9493
void LoadOptions();
9594
void SaveOptions();
9695
void SavePosition();

0 commit comments

Comments
 (0)