瀏覽代碼

Bug fix: When "Keep remote directory up to date" function was started from command-line, disconnects were not detected. + Bug fix: When connection was lost, the "Keep remote directory up to date" window was not closed.

(cherry picked from commit 659e76206888b1f79943732cd72ccd9b70e2e796)

Source commit: 4c29a0b6a90abac8dabfc04564cce64157665593
Martin Prikryl 4 年之前
父節點
當前提交
4c71ffa503

+ 24 - 8
source/forms/CustomScpExplorer.cpp

@@ -206,8 +206,10 @@ __fastcall TCustomScpExplorerForm::TCustomScpExplorerForm(TComponent* Owner):
   FLastContextPopupScreenPoint = TPoint(-1, -1);
   FTransferResumeList = NULL;
   FMoveToQueue = false;
-  FStandaloneEditing = false;
+  StandaloneOperation = false;
   FOnFeedSynchronizeError = NULL;
+  FOnSynchronizeAbort = NULL;
+  FSynchronizeTerminal = NULL;
   FNeedSession = false;
   FDoNotIdleCurrentTerminal = 0;
   FIncrementalSearching = 0;
@@ -802,7 +804,7 @@ bool __fastcall TCustomScpExplorerForm::IsQueueAutoPopup()
 {
   // during standalone editing, we have no way to see/control queue,
   // so we have to always popup prompts automatically
-  return FStandaloneEditing || GUIConfiguration->QueueAutoPopup;
+  return StandaloneOperation || GUIConfiguration->QueueAutoPopup;
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::RefreshQueueItems()
@@ -3193,7 +3195,7 @@ void __fastcall TCustomScpExplorerForm::CustomExecuteFile(TOperationSide Side,
         Editor = ShowEditorForm(FileName, this, OnFileChanged,
           FEditorManager->FileReload, FEditorManager->FileClosed,
           OnSaveAll, OnAnyModified,
-          Caption, FStandaloneEditing, SessionColor, Terminal->SessionData->InternalEditorEncoding, NewFile);
+          Caption, StandaloneOperation, SessionColor, Terminal->SessionData->InternalEditorEncoding, NewFile);
       }
       catch(...)
       {
@@ -3208,7 +3210,7 @@ void __fastcall TCustomScpExplorerForm::CustomExecuteFile(TOperationSide Side,
     }
     else
     {
-      DebugAssert(!FStandaloneEditing);
+      DebugAssert(!StandaloneOperation);
       TForm * Editor =
         ShowEditorForm(FileName, this, NULL, NULL, LocalEditorClosed,
           SaveAllInternalEditors, AnyInternalEditorModified,
@@ -4620,7 +4622,10 @@ void __fastcall TCustomScpExplorerForm::UpdateStatusPanelText(TTBXStatusPanel *
 void __fastcall TCustomScpExplorerForm::Idle()
 {
 
-  if (FShowing || FStandaloneEditing)
+  if (FShowing ||
+      // Particularly to detect closed connection and automatically reconnect it while waiting for changes
+      // while "keeping remote directory up to date"
+      StandaloneOperation)
   {
     FEditorManager->Check();
 
@@ -4660,7 +4665,7 @@ void __fastcall TCustomScpExplorerForm::Idle()
     }
   }
 
-  if (FShowing || FStandaloneEditing)
+  if (FShowing || StandaloneOperation)
   {
     if (FQueueStatusInvalidated)
     {
@@ -5388,9 +5393,12 @@ bool __fastcall TCustomScpExplorerForm::DoSynchronizeDirectories(
     int Options =
       FLAGMASK(SynchronizeAllowSelectedOnly(), soAllowSelectedOnly);
     DebugAssert(FOnFeedSynchronizeError == NULL);
+    DebugAssert(FOnSynchronizeAbort == NULL);
+    DebugAssert(FSynchronizeTerminal == NULL);
+    FSynchronizeTerminal = Terminal;
     Result = DoSynchronizeDialog(Params, &CopyParam, Controller.StartStop,
       SaveSettings, Options, CopyParamAttrs, GetSynchronizeOptions, SynchronizeSessionLog,
-      FOnFeedSynchronizeError, SynchronizeInNewWindow, UseDefaults);
+      FOnFeedSynchronizeError, FOnSynchronizeAbort, SynchronizeInNewWindow, UseDefaults);
     if (Result)
     {
       if (SaveSettings)
@@ -5418,6 +5426,9 @@ bool __fastcall TCustomScpExplorerForm::DoSynchronizeDirectories(
     FSynchronizeController = NULL;
     DebugAssert(FOnFeedSynchronizeError == NULL);
     FOnFeedSynchronizeError = NULL;
+    DebugAssert(FOnSynchronizeAbort == NULL);
+    FOnSynchronizeAbort = NULL;
+    FSynchronizeTerminal = NULL;
   }
   return Result;
 }
@@ -6039,7 +6050,6 @@ void __fastcall TCustomScpExplorerForm::StandaloneEdit(const UnicodeString & Fil
   if (File != NULL)
   {
     std::unique_ptr<TRemoteFile> FileOwner(File);
-    TAutoFlag Flag(FStandaloneEditing);
 
     ExecuteRemoteFile(FullFileName, File, efInternalEditor);
 
@@ -6656,6 +6666,12 @@ void __fastcall TCustomScpExplorerForm::DetachTerminal(TObject * ATerminal)
   {
     ClipboardClear(); // implies ClipboardStop
   }
+
+  if ((FOnSynchronizeAbort != NULL) &&
+      (ATerminal == FManagedSession))
+  {
+    FOnSynchronizeAbort(NULL);
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::TerminalRemoved(TObject * Sender)

+ 4 - 1
source/forms/CustomScpExplorer.h

@@ -285,8 +285,10 @@ private:
   HWND FHiddenWindow;
   TStrings * FTransferResumeList;
   bool FMoveToQueue;
-  bool FStandaloneEditing;
+  bool FStandaloneOperation;
   TFeedSynchronizeError FOnFeedSynchronizeError;
+  TNotifyEvent FOnSynchronizeAbort;
+  TTerminal * FSynchronizeTerminal;
   bool FNeedSession;
   TTerminal * FFileFindTerminal;
   UnicodeString FFileColorsCurrent;
@@ -856,6 +858,7 @@ public:
   __property TManagedTerminal * Terminal = { read = FTerminal, write = SetTerminal };
   __property TTerminalQueue * Queue = { read = FQueue, write = SetQueue };
   __property TColor SessionColor = { read = FSessionColor, write = SetSessionColor };
+  __property bool StandaloneOperation = { read = FStandaloneOperation, write = FStandaloneOperation };
 };
 //---------------------------------------------------------------------------
 #endif

+ 18 - 2
source/forms/Synchronize.cpp

@@ -33,13 +33,16 @@ bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params,
   TGetSynchronizeOptionsEvent OnGetOptions,
   TSynchronizeSessionLog OnSynchronizeSessionLog,
   TFeedSynchronizeError & OnFeedSynchronizeError,
+  TNotifyEvent & OnSynchronizeAbort,
   TSynchronizeInNewWindow OnSynchronizeInNewWindow,
   int AutoSubmit)
 {
   bool Result;
   TSynchronizeDialog * Dialog = SafeFormCreate<TSynchronizeDialog>(Application);
 
-  Dialog->Init(OnStartStop, OnGetOptions, OnSynchronizeSessionLog, OnFeedSynchronizeError, OnSynchronizeInNewWindow, AutoSubmit);
+  Dialog->Init(
+    OnStartStop, OnGetOptions, OnSynchronizeSessionLog, OnFeedSynchronizeError, OnSynchronizeAbort,
+    OnSynchronizeInNewWindow, AutoSubmit);
 
   try
   {
@@ -58,6 +61,7 @@ bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params,
   __finally
   {
     delete Dialog;
+    OnSynchronizeAbort = NULL;
   }
 
   return Result;
@@ -95,6 +99,7 @@ void __fastcall TSynchronizeDialog::Init(TSynchronizeStartStopEvent OnStartStop,
   TGetSynchronizeOptionsEvent OnGetOptions,
   TSynchronizeSessionLog OnSynchronizeSessionLog,
   TFeedSynchronizeError & OnFeedSynchronizeError,
+  TNotifyEvent & OnSynchronizeAbort,
   TSynchronizeInNewWindow OnSynchronizeInNewWindow,
   int AutoSubmit)
 {
@@ -102,6 +107,7 @@ void __fastcall TSynchronizeDialog::Init(TSynchronizeStartStopEvent OnStartStop,
   FOnGetOptions = OnGetOptions;
   FOnSynchronizeSessionLog = OnSynchronizeSessionLog;
   FOnFeedSynchronizeError = &OnFeedSynchronizeError;
+  OnSynchronizeAbort = &SynchronizeAbort;
   DebugAssert(OnSynchronizeInNewWindow != NULL);
   FOnSynchronizeInNewWindow = OnSynchronizeInNewWindow;
   if (AutoSubmit == 0)
@@ -142,6 +148,11 @@ void __fastcall TSynchronizeDialog::FeedSynchronizeError(
   DoLogInternal(slContinuedError, Message, MoreMessages, Type, HelpKeyword);
 }
 //---------------------------------------------------------------------------
+void __fastcall TSynchronizeDialog::SynchronizeAbort(TObject *)
+{
+  Abort(true);
+}
+//---------------------------------------------------------------------------
 void __fastcall TSynchronizeDialog::UpdateControls()
 {
   EnableControl(StartButton, !LocalDirectoryEdit->Text.IsEmpty() &&
@@ -361,13 +372,18 @@ void __fastcall TSynchronizeDialog::Dispatch(void * AMessage)
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TSynchronizeDialog::DoAbort(TObject * /*Sender*/, bool Close)
+void TSynchronizeDialog::Abort(bool Close)
 {
   FAbort = true;
   FClose = Close;
   PostMessage(Handle, WM_USER_STOP, 0, 0);
 }
 //---------------------------------------------------------------------------
+void __fastcall TSynchronizeDialog::DoAbort(TObject * /*Sender*/, bool Close)
+{
+  Abort(Close);
+}
+//---------------------------------------------------------------------------
 void __fastcall TSynchronizeDialog::DoLogInternal(
   TSynchronizeLogEntry Entry, const UnicodeString & Message,
   TStrings * MoreMessages, TQueryType Type, const UnicodeString & HelpKeyword)

+ 5 - 1
source/forms/Synchronize.h

@@ -126,6 +126,7 @@ protected:
   void __fastcall FeedSynchronizeError(
     const UnicodeString & Message, TStrings * MoreMessages, TQueryType Type,
     const UnicodeString & HelpKeyword);
+  void __fastcall SynchronizeAbort(TObject *);
   TLogItemData * __fastcall GetLogItemData(TListItem * Item);
   void __fastcall Minimize(TObject * Sender);
   void __fastcall Start();
@@ -134,6 +135,7 @@ protected:
   void __fastcall UpdateControls();
   bool __fastcall AllowStartInNewWindow();
   bool __fastcall CanStartInNewWindow();
+  void Abort(bool Close);
 
   INTERFACE_HOOK;
 
@@ -142,7 +144,9 @@ public:
   void __fastcall Init(TSynchronizeStartStopEvent OnStartStop,
     TGetSynchronizeOptionsEvent OnGetOptions,
     TSynchronizeSessionLog OnSynchronizeSessionLog,
-    TFeedSynchronizeError & OnFeedSynchronizeError, TSynchronizeInNewWindow OnSynchronizeInNewWindow,
+    TFeedSynchronizeError & OnFeedSynchronizeError,
+    TNotifyEvent & OnSynchronizeAbort,
+    TSynchronizeInNewWindow OnSynchronizeInNewWindow,
     int AutoSubmit);
   virtual __fastcall ~TSynchronizeDialog();
 

+ 1 - 0
source/windows/WinInterface.h

@@ -344,6 +344,7 @@ bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params,
   TGetSynchronizeOptionsEvent OnGetOptions,
   TSynchronizeSessionLog OnSynchronizeSessionLog,
   TFeedSynchronizeError & OnFeedSynchronizeError,
+  TNotifyEvent & OnSynchronizeAbort,
   TSynchronizeInNewWindow OnSynchronizeInNewWindow,
   int AutoSubmit);
 

+ 3 - 0
source/windows/WinMain.cpp

@@ -1217,6 +1217,7 @@ int __fastcall Execute()
                   if ((ParamCommand != pcNone) || !DownloadFile.IsEmpty())
                   {
                     Configuration->Usage->Inc(L"CommandLineOperation");
+                    ScpExplorer->StandaloneOperation = true;
                   }
 
                   if (ParamCommand == pcUpload)
@@ -1250,6 +1251,8 @@ int __fastcall Execute()
                     }
                   }
 
+                  ScpExplorer->StandaloneOperation = false;
+
                   if (Browse)
                   {
                     ScpExplorer->BrowseFile();