Ver código fonte

Avoiding a short hang of GUI, when waiting for edited file to be saved

Source commit: e462ef520cb9629855d2b8d60b9afe0b4afb8da8
Martin Prikryl 8 anos atrás
pai
commit
f63fefc78b
1 arquivos alterados com 10 adições e 4 exclusões
  1. 10 4
      source/windows/EditorManager.cpp

+ 10 - 4
source/windows/EditorManager.cpp

@@ -9,6 +9,7 @@
 #include "WinConfiguration.h"
 #include "EditorManager.h"
 #include <algorithm>
+#include <DateUtils.hpp>
 //---------------------------------------------------------------------------
 #pragma package(smart_init)
 //---------------------------------------------------------------------------
@@ -243,11 +244,16 @@ void __fastcall TEditorManager::Check()
     TDateTime NewTimestamp;
     if (HasFileChanged(Index, NewTimestamp))
     {
-      // let the editor finish writing to the file
+      TDateTime N = Now();
+      // Let the editor finish writing to the file
       // (first to avoid uploading partially saved file, second
-      // because the timestamp may change more than once during saving)
-      Sleep(GUIConfiguration->KeepUpToDateChangeDelay);
-      CheckFileChange(Index, false);
+      // because the timestamp may change more than once during saving).
+      // WORKAROUND WithinPastMilliSeconds seems buggy that it return true even if NewTimestamp is within future
+      if ((NewTimestamp <= N) &&
+          !WithinPastMilliSeconds(N, NewTimestamp, GUIConfiguration->KeepUpToDateChangeDelay))
+      {
+        CheckFileChange(Index, false);
+      }
     }
   }