OSDN Git Service

Fix issue where active pane is not restored correctly
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 21 Dec 2019 13:33:16 +0000 (22:33 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 21 Dec 2019 13:33:35 +0000 (22:33 +0900)
Src/HexMergeFrm.cpp
Src/HexMergeFrm.h
Src/ImgMergeFrm.cpp
Src/ImgMergeFrm.h
Src/MergeDoc.cpp
Src/MergeEditFrm.cpp
Src/MergeEditFrm.h

index 19ac526..baf1661 100644 (file)
@@ -209,11 +209,14 @@ BOOL CHexMergeFrame::DestroyWindow()
  * @note Do not save the maximized/restored state here. We are interested
  * in the state of the active frame, and maybe this frame is not active
  */
-void CHexMergeFrame::SavePosition()
+void CHexMergeFrame::SavePosition(bool bSaveActivePane)
 {
-       if (CWnd *pLeft = m_wndSplitter.GetPane(0,0))
+       if (bSaveActivePane)
        {
-               GetOptionsMgr()->SaveOption(OPT_ACTIVE_PANE, GetActivePane());
+               if (CWnd* pLeft = m_wndSplitter.GetPane(0, 0))
+               {
+                       GetOptionsMgr()->SaveOption(OPT_ACTIVE_PANE, GetActivePane());
+               }
        }
 }
 
@@ -407,6 +410,6 @@ void CHexMergeFrame::UpdateResources()
  */
 LRESULT CHexMergeFrame::OnStorePaneSizes(WPARAM wParam, LPARAM lParam)
 {
-       SavePosition();
+       SavePosition(false);
        return 0;
 }
index fa37a80..2adbb3c 100644 (file)
@@ -73,7 +73,7 @@ public:
 
 // Implementation
 private:
-       void SavePosition();
+       void SavePosition(bool bSaveActivePane = true);
        virtual ~CHexMergeFrame();
        void CreateHexWndStatusBar(CStatusBar &, CWnd *);
 // Generated message map functions
index 1df998e..b4e7492 100644 (file)
@@ -600,11 +600,10 @@ void CImgMergeFrame::SaveOptions()
  * @note Do not save the maximized/restored state here. We are interested
  * in the state of the active frame, and maybe this frame is not active
  */
-void CImgMergeFrame::SavePosition()
+void CImgMergeFrame::SavePosition(bool bSaveActivePane)
 {
        CRect rc;
        GetWindowRect(&rc);
-       GetOptionsMgr()->SaveOption(OPT_ACTIVE_PANE, m_pImgMergeWindow->GetActivePane());
 
        // save the bars layout
        // save docking positions and sizes
@@ -613,6 +612,9 @@ void CImgMergeFrame::SavePosition()
        m_pDockState.SaveState(_T("Settings-ImgMergeFrame"));
        // for the dimensions of the diff pane, use the CSizingControlBar save
        m_wndLocationBar.SaveState(_T("Settings-ImgMergeFrame"));
+
+       if (bSaveActivePane)
+               GetOptionsMgr()->SaveOption(OPT_ACTIVE_PANE, m_pImgMergeWindow->GetActivePane());
 }
 
 void CImgMergeFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
@@ -1335,7 +1337,7 @@ void CImgMergeFrame::OnIdleUpdateCmdUI()
  */
 LRESULT CImgMergeFrame::OnStorePaneSizes(WPARAM wParam, LPARAM lParam)
 {
-       SavePosition();
+       SavePosition(false);
        return 0;
 }
 
index b0ea500..b76f63b 100644 (file)
@@ -100,7 +100,7 @@ private:
        bool EnsureValidDockState(CDockState& state);
        void LoadOptions();
        void SaveOptions();
-       void SavePosition();
+       void SavePosition(bool bSaveActivePane = true);
        virtual ~CImgMergeFrame();
        void CreateImgWndStatusBar(CStatusBar &, CWnd *);
 // Generated message map functions
index 55ff1f6..1a6afa8 100644 (file)
@@ -2841,8 +2841,7 @@ void CMergeDoc::MoveOnLoad(int nPane, int nLineIndex)
                        nLineIndex = m_pView[0][nPane]->GetCursorPos().y;
                }
        }
-       if (nLineIndex != -1)
-               m_pView[0][nPane]->GotoLine(nLineIndex, false, nPane);
+       m_pView[0][nPane]->GotoLine(nLineIndex < 0 ? 0 : nLineIndex, false, nPane);
 }
 
 void CMergeDoc::ChangeFile(int nBuffer, const String& path)
index 9e2b671..4fc6059 100644 (file)
@@ -286,7 +286,7 @@ BOOL CMergeEditFrame::DestroyWindow()
  * @note Do not save the maximized/restored state here. We are interested
  * in the state of the active frame, and maybe this frame is not active
  */
-void CMergeEditFrame::SavePosition()
+void CMergeEditFrame::SavePosition(bool bSaveActivePane)
 {
        // save the bars layout
        // save docking positions and sizes
@@ -297,13 +297,16 @@ void CMergeEditFrame::SavePosition()
        m_wndLocationBar.SaveState(_T("Settings"));
        m_wndDetailBar.SaveState(_T("Settings"));
 
-       for (int iRowParent = 0; iRowParent < m_wndSplitter.GetRowCount(); ++iRowParent)
+       if (bSaveActivePane)
        {
-               int iRow, iCol;
-               auto& splitterWnd = static_cast<CMergeEditSplitterView *>(m_wndSplitter.GetPane(iRowParent, 0))->m_wndSplitter;
-               splitterWnd.GetActivePane(&iRow, &iCol);
-               if (iRow >= 0 || iCol >= 0)
-                       GetOptionsMgr()->SaveOption(OPT_ACTIVE_PANE, max(iRow, iCol));
+               for (int iRowParent = 0; iRowParent < m_wndSplitter.GetRowCount(); ++iRowParent)
+               {
+                       int iRow, iCol;
+                       auto& splitterWnd = static_cast<CMergeEditSplitterView*>(m_wndSplitter.GetPane(iRowParent, 0))->m_wndSplitter;
+                       splitterWnd.GetActivePane(&iRow, &iCol);
+                       if (iRow >= 0 || iCol >= 0)
+                               GetOptionsMgr()->SaveOption(OPT_ACTIVE_PANE, max(iRow, iCol));
+               }
        }
 }
 
@@ -390,7 +393,7 @@ void CMergeEditFrame::OnTimer(UINT_PTR nIDEvent)
 {
        if (nIDEvent == IDT_SAVEPOSITION)
        {
-               SavePosition();
+               SavePosition(false);
                KillTimer(IDT_SAVEPOSITION);
        }
        else
index 4b1d155..12edd9d 100644 (file)
@@ -78,7 +78,7 @@ public:
 // Implementation
 private:
        bool EnsureValidDockState(CDockState& state);
-       void SavePosition();
+       void SavePosition(bool bSaveActivePane = true);
        virtual ~CMergeEditFrame();
        CSplitterWndEx& GetMergeEditSplitterWnd(int iRow)
        { return static_cast<CMergeEditSplitterView *>(m_wndSplitter.GetPane(iRow, 0))->m_wndSplitter; }