瀏覽代碼

Bug 1429: Failure when reloading edited file while it's being reloaded already

https://winscp.net/tracker/1429

Source commit: e034954ef573af34b0e42b4e6fbc2bcd27fc627b
Martin Prikryl 9 年之前
父節點
當前提交
04d416b785
共有 3 個文件被更改,包括 10 次插入1 次删除
  1. 2 0
      source/forms/CustomScpExplorer.cpp
  2. 7 1
      source/forms/Editor.cpp
  3. 1 0
      source/forms/Editor.h

+ 2 - 0
source/forms/CustomScpExplorer.cpp

@@ -3338,6 +3338,7 @@ void __fastcall TCustomScpExplorerForm::ExecutedFileReload(
 
   TTerminal * PrevTerminal = TTerminalManager::Instance()->ActiveTerminal;
   TTerminalManager::Instance()->ActiveTerminal = Data->Terminal;
+  NonVisualDataModule->StartBusy();
   try
   {
     std::unique_ptr<TRemoteFile> File;
@@ -3372,6 +3373,7 @@ void __fastcall TCustomScpExplorerForm::ExecutedFileReload(
   }
   __finally
   {
+    NonVisualDataModule->EndBusy();
     // it actually may not exist anymore...
     TTerminalManager::Instance()->ActiveTerminal = PrevTerminal;
   }

+ 7 - 1
source/forms/Editor.cpp

@@ -684,6 +684,7 @@ __fastcall TEditorForm::TEditorForm(TComponent* Owner)
   FSaving = false;
   FStandaloneEditor = false;
   FClosePending = false;
+  FReloading = false;
   SetSubmenu(ColorItem);
 
   InitCodePage();
@@ -800,10 +801,14 @@ void __fastcall TEditorForm::EditorActionsUpdate(TBasicAction *Action,
   }
   else if (Action == PreferencesAction ||
     Action == FindAction || Action == ReplaceAction || Action == GoToLineAction ||
-    Action == HelpAction || Action == ReloadAction || Action == ColorAction)
+    Action == HelpAction || Action == ColorAction)
   {
     ((TAction *)Action)->Enabled = true;
   }
+  else if (Action == ReloadAction)
+  {
+    ReloadAction->Enabled = !FReloading;
+  }
   else if (Action == DefaultEncodingAction)
   {
     DefaultEncodingAction->Enabled = true;
@@ -1546,6 +1551,7 @@ void __fastcall TEditorForm::CreateParams(TCreateParams & Params)
 //---------------------------------------------------------------------------
 void __fastcall TEditorForm::Reload()
 {
+  TAutoFlag ReloadingFlag(FReloading);
   if (!IsFileModified() ||
       (MessageDialog(MainInstructions(LoadStr(EDITOR_MODIFIED_RELOAD)), qtConfirmation,
         qaOK | qaCancel) != qaCancel))

+ 1 - 0
source/forms/Editor.h

@@ -116,6 +116,7 @@ private:
   bool FStandaloneEditor;
   bool FClosePending;
   TColor FBackgroundColor;
+  bool FReloading;
 
   static unsigned int FInstances;
   void __fastcall SetFileName(const UnicodeString value);