OSDN Git Service

PATCH: [ 838283 ] Simplifiy OnFileSave
authorPerry Rapp <elsapo@users.sourceforge.net>
Sat, 8 Nov 2003 22:57:47 +0000 (22:57 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Sat, 8 Nov 2003 22:57:47 +0000 (22:57 +0000)
Src/MergeDoc.cpp
Src/readme.txt

index 279ee98..53c8a10 100644 (file)
@@ -1624,27 +1624,34 @@ void CMergeDoc::FlushAndRescan(BOOL bForced /* =FALSE */)
  */
 void CMergeDoc::OnFileSave() 
 {
-       BOOL bLSaveSuccess = FALSE;
-       BOOL bRSaveSuccess = FALSE;
-       BOOL bLModified = FALSE;
-       BOOL bRModified = FALSE;
+       // We will need to know if either of the originals actually changed
+       // so we know whether to update the diff status
+       BOOL bLChangedOriginal = FALSE;
+       BOOL bRChangedOriginal = FALSE;
 
        if (m_ltBuf.IsModified() && !m_ltBuf.GetReadOnly())
        {
-               bLModified = TRUE;
-               DoSave(m_strLeftFile, bLSaveSuccess, TRUE );
+               // (why we don't use return value of DoSave)
+               // DoSave will return TRUE if it wrote to something successfully
+               // but we have to know if it overwrote the original file
+               BOOL bSaveOriginal = FALSE;
+               DoSave(m_strLeftFile, bSaveOriginal, TRUE );
+               if (bSaveOriginal)
+                       bLChangedOriginal = TRUE;
        }
 
        if (m_rtBuf.IsModified() && !m_rtBuf.GetReadOnly())
        {
-               bRModified = TRUE;
-               DoSave(m_strRightFile, bRSaveSuccess, FALSE);
+               // See comments above for left case
+               BOOL bSaveOriginal = FALSE;
+               DoSave(m_strRightFile, bSaveOriginal, FALSE);
+               if (bSaveOriginal)
+                       bRChangedOriginal = TRUE;
        }
 
-       // If file were modified and saving succeeded,
-       // update status on dir view
-       if ((bLModified && bLSaveSuccess) || 
-               (bRModified && bRSaveSuccess))
+       // If either of the actual source files being compared was changed
+       // we need to update status in the dir view
+       if (bLChangedOriginal || bRChangedOriginal)
        {
                // If DirDoc contains diffs
                if (m_pDirDoc->m_pCtxt)
index 3270371..18d7b72 100644 (file)
@@ -1,6 +1,10 @@
-2003-11-05 WinMerge experimental release 2.1.3.8 (patch demo)
+2003-11-08 Perry
+ PATCH: [ 838283 ] Simplifiy OnFileSave
+  WinMerge: MergeDoc.cpp
+
+2003-11-08 WinMerge experimental release 2.1.3.8 (patch demo)
 
-2003-11-05 WinMerge experimental release 2.1.3.7 (cvs)
+2003-11-08 WinMerge experimental release 2.1.3.7 (cvs)
 
 2003-11-08 Laoran
  BUG: [ 838248 ] possible typo in plugin code (cosmetic)