OSDN Git Service

Fix crash when saving files after following steps: 2.13.20+-jp-9
authorsdottaka <none@none>
Wed, 28 Dec 2011 14:23:11 +0000 (23:23 +0900)
committersdottaka <none@none>
Wed, 28 Dec 2011 14:23:11 +0000 (23:23 +0900)
1. Compare folders.
2. Compare files from folder view.
3. Click the tab of the folder view and select [hide items] menu item of the opened files.
4. Save the opened files -> crash!

Src/DirDoc.cpp
Src/DirDoc.h

index e7580ed..b2b1469 100644 (file)
@@ -538,23 +538,24 @@ void CDirDoc::UpdateStatusFromDisk(UINT_PTR diffPos, BOOL bLeft, BOOL bRight)
 
 /**
  * @brief Update in-memory diffitem status from disk and update view.
- * @param [in] nIdx Index of item in UI list.
+ * @param [in] diffPos POSITION of item in UI list.
  * @param [in] bLeft If TRUE left-side item is updated.
  * @param [in] bRight If TRUE right-side item is updated.
  * @note Do not call this function from DirView code! This function
  * calls slow DirView functions to get item position and to update GUI.
  * Use UpdateStatusFromDisk() function instead.
  */
-void CDirDoc::ReloadItemStatus(UINT nIdx, BOOL bLeft, BOOL bRight)
+void CDirDoc::ReloadItemStatus(UINT_PTR diffPos, BOOL bLeft, BOOL bRight)
 {
-       // Get position of item in DiffContext
-       UINT_PTR diffpos = m_pDirView->GetItemKey(nIdx);
-
        // in case just copied (into existence) or modified
-       UpdateStatusFromDisk(diffpos, bLeft, bRight);
+       UpdateStatusFromDisk(diffPos, bLeft, bRight);
 
-       // Update view
-       m_pDirView->UpdateDiffItemStatus(nIdx);
+       int nIdx = m_pDirView->GetItemIndex(diffPos);
+       if (nIdx != -1)
+       {
+               // Update view
+               m_pDirView->UpdateDiffItemStatus(nIdx);
+       }
 }
 
 void CDirDoc::InitStatusStrings()
@@ -819,17 +820,15 @@ void CDirDoc::UpdateChangedItem(PathContext &paths,
        // so there really is not status to update.
        if (pos > 0)
        {
-               int ind = m_pDirView->GetItemIndex(pos);
-
                // Figure out new status code
                UINT diffcode = (bIdentical ? DIFFCODE::SAME : DIFFCODE::DIFF);
 
                // Update both views and diff context memory
-               SetDiffCompare(diffcode, ind);
+               m_pCtxt->SetDiffStatusCode(pos, diffcode, DIFFCODE::COMPAREFLAGS);
 
                if (nDiffs != -1 && nTrivialDiffs != -1)
-                       SetDiffCounts(nDiffs, nTrivialDiffs, ind);
-               ReloadItemStatus(ind, TRUE, TRUE);
+                       m_pCtxt->SetDiffCounts(pos, nDiffs, nTrivialDiffs);
+               ReloadItemStatus(pos, TRUE, TRUE);
        }
 }
 
index c0ccc62..4b59d8f 100644 (file)
@@ -105,7 +105,7 @@ public:
        void UpdateResources();
        void InitStatusStrings();
        void UpdateStatusFromDisk(UINT_PTR diffPos, BOOL bLeft, BOOL bRight);
-       void ReloadItemStatus(UINT nIdx, BOOL bLeft, BOOL bRight);
+       void ReloadItemStatus(UINT_PTR diffPos, BOOL bLeft, BOOL bRight);
        void Redisplay();
        virtual ~CDirDoc();
        void SetDirView( CDirView *newView ); // TODO Perry