OSDN Git Service

PATCH: [ 1374782 ] fix for bug 1300957 Crash on save 'unique' file comparison
authorKimmo Varis <kimmov@gmail.com>
Thu, 8 Dec 2005 19:45:33 +0000 (19:45 +0000)
committerKimmo Varis <kimmov@gmail.com>
Thu, 8 Dec 2005 19:45:33 +0000 (19:45 +0000)
 - submitted by Oliver Mellet, some additional comment improvements by me.

Src/Changes.txt
Src/DirDoc.cpp

index f1e2fe9..6933ed0 100644 (file)
@@ -1,3 +1,8 @@
+2005-12-08 Kimmo
+ PATCH: [ 1374782 ] fix for bug 1300957 Crash on save 'unique' file comparison
+  Submitted by Oliver Mellet, some additional comment improvements by me.
+  Src: DirDoc.cpp
+
 2005-12-08 Perry
  PATCH: [ 1376457 ] Need clarification in platform test in ShellExtension
   ShellExtension: ShellExtension.cpp
index 68b3893..95b6366 100644 (file)
@@ -625,28 +625,32 @@ CMergeDoc * CDirDoc::GetMergeDocForDiff(BOOL * pNew)
  * @param [in] nDiffs Total amount of differences
  * @param [in] nTrivialDiffs Amount of ignored differences
  * @param [in] bIdentical TRUE if files became identical, FALSE otherwise.
- * @note Filenames must be same, otherwise function asserts.
  */
 void CDirDoc::UpdateChangedItem(PathContext &paths,
        UINT nDiffs, UINT nTrivialDiffs, BOOL bIdentical)
 {
        POSITION pos = FindItemFromPaths(paths.GetLeft(), paths.GetRight());
-       // TODO: when this happens?
+       // If we failed files could have been swapped so lets try again
        if (!pos)
-               // Two files were swapped.
                pos = FindItemFromPaths(paths.GetRight(), paths.GetLeft());
-       ASSERT(pos);
-       int ind = m_pDirView->GetItemIndex((DWORD)pos);
+       
+       // Update status if paths were found for items.
+       // Fail means we had unique items compared as 'renamed' items
+       // so there really is not status to update.
+       if (pos > 0)
+       {
+               int ind = m_pDirView->GetItemIndex((DWORD)pos);
 
-       // Figure out new status code
-       UINT diffcode = (bIdentical ? DIFFCODE::SAME : DIFFCODE::DIFF);
+               // Figure out new status code
+               UINT diffcode = (bIdentical ? DIFFCODE::SAME : DIFFCODE::DIFF);
 
-       // Update both views and diff context memory
-       SetDiffCompare(diffcode, ind);
+               // Update both views and diff context memory
+               SetDiffCompare(diffcode, ind);
 
-       if (nDiffs != -1 && nTrivialDiffs != -1)
-               SetDiffCounts(nDiffs, nTrivialDiffs, ind);
-       ReloadItemStatus(ind, TRUE, TRUE);
+               if (nDiffs != -1 && nTrivialDiffs != -1)
+                       SetDiffCounts(nDiffs, nTrivialDiffs, ind);
+               ReloadItemStatus(ind, TRUE, TRUE);
+       }
 }
 
 /**