1
0
Эх сурвалжийг харах

Bug fix: When files on another session tab, the "Duplicate via local temporary copy" could be unchecked (and was initially unchecked), leading to the file being duplicated incorrectly within the current session.

(cherry picked from commit 6e9a36fe0aaf100b29e58a41b0a4968ce4eac5cd)

Conflicts:
	source/forms/CustomScpExplorer.cpp
	source/forms/RemoteTransfer.cpp
	source/forms/RemoteTransfer.h
	source/windows/WinInterface.h

Source commit: 264f84c17366afdd21bd518acbfb89a882759a57
Martin Prikryl 9 жил өмнө
parent
commit
f951ee9f77

+ 1 - 1
source/forms/CustomScpExplorer.cpp

@@ -3434,7 +3434,7 @@ bool __fastcall TCustomScpExplorerForm::RemoteTransferDialog(TTerminal *& Sessio
         }
         void * ASession = Session;
         Result = DoRemoteCopyDialog(Sessions, Directories, AllowDirectCopy,
-          ASession, Target, FileMask, DirectCopy);
+          ASession, Target, FileMask, DirectCopy, TTerminalManager::Instance()->ActiveTerminal);
         Session = static_cast<TTerminal *>(ASession);
       }
       __finally

+ 20 - 12
source/forms/RemoteTransfer.cpp

@@ -19,13 +19,13 @@
 //---------------------------------------------------------------------------
 bool __fastcall DoRemoteCopyDialog(TStrings * Sessions, TStrings * Directories,
   TDirectRemoteCopy AllowDirectCopy, void *& Session, UnicodeString & Target, UnicodeString & FileMask,
-  bool & DirectCopy)
+  bool & DirectCopy, void * CurrentSession)
 {
   bool Result;
   TRemoteTransferDialog * Dialog = SafeFormCreate<TRemoteTransferDialog>();
   try
   {
-    Dialog->Init(Sessions, Directories, AllowDirectCopy);
+    Dialog->Init(Sessions, Directories, AllowDirectCopy, CurrentSession);
     Result = Dialog->Execute(Session, Target, FileMask, DirectCopy);
   }
   __finally
@@ -44,33 +44,31 @@ __fastcall TRemoteTransferDialog::TRemoteTransferDialog(TComponent * Owner)
 }
 //---------------------------------------------------------------------------
 void __fastcall TRemoteTransferDialog::Init(TStrings * Sessions,
-  TStrings * Directories, TDirectRemoteCopy AllowDirectCopy)
+  TStrings * Directories, TDirectRemoteCopy AllowDirectCopy, void * CurrentSession)
 {
   SessionCombo->Items = Sessions;
   FDirectories = Directories;
   assert(SessionCombo->Items->Count > 0);
   assert(SessionCombo->Items->Count == FDirectories->Count);
   FAllowDirectCopy = AllowDirectCopy;
+  FCurrentSession = CurrentSession;
 }
 //---------------------------------------------------------------------------
 bool __fastcall TRemoteTransferDialog::Execute(void *& Session, UnicodeString & Target,
   UnicodeString & FileMask, bool & DirectCopy)
 {
-  FCurrentSession = -1;
   for (int Index = 0; Index < SessionCombo->Items->Count; Index++)
   {
     if (SessionCombo->Items->Objects[Index] == Session)
     {
-      FCurrentSession = Index;
       SessionCombo->ItemIndex = Index;
       break;
     }
   }
-  assert(FCurrentSession >= 0);
   DirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteTarget"];
   DirectoryEdit->Text = UnixIncludeTrailingBackslash(Target) + FileMask;
   FDirectCopy = DirectCopy;
-  NotDirectCopyCheck->Checked = !DirectCopy;
+  UpdateNotDirectCopyCheck();
   bool Result = (ShowModal() == DefaultResult(this));
   if (Result)
   {
@@ -86,7 +84,7 @@ bool __fastcall TRemoteTransferDialog::Execute(void *& Session, UnicodeString &
 void __fastcall TRemoteTransferDialog::UpdateControls()
 {
   EnableControl(NotDirectCopyCheck,
-    (SessionCombo->ItemIndex == FCurrentSession) &&
+    IsCurrentSessionSelected() &&
     (FAllowDirectCopy != drcDisallow));
   EnableControl(OkButton, !DirectoryEdit->Text.IsEmpty());
 }
@@ -114,7 +112,13 @@ void __fastcall TRemoteTransferDialog::SessionComboChange(TObject * /*Sender*/)
   DirectoryEdit->Text =
     UnixIncludeTrailingBackslash(FDirectories->Strings[SessionCombo->ItemIndex]) +
     UnixExtractFileName(DirectoryEdit->Text);
-  if (SessionCombo->ItemIndex == FCurrentSession)
+  UpdateNotDirectCopyCheck();
+  UpdateControls();
+}
+//---------------------------------------------------------------------------
+void __fastcall TRemoteTransferDialog::UpdateNotDirectCopyCheck()
+{
+  if (IsCurrentSessionSelected())
   {
     NotDirectCopyCheck->Checked = !FDirectCopy;
   }
@@ -122,7 +126,6 @@ void __fastcall TRemoteTransferDialog::SessionComboChange(TObject * /*Sender*/)
   {
     NotDirectCopyCheck->Checked = true;
   }
-  UpdateControls();
 }
 //---------------------------------------------------------------------------
 void __fastcall TRemoteTransferDialog::FormCloseQuery(TObject * /*Sender*/,
@@ -130,7 +133,7 @@ void __fastcall TRemoteTransferDialog::FormCloseQuery(TObject * /*Sender*/,
 {
   if (ModalResult == DefaultResult(this))
   {
-    if ((SessionCombo->ItemIndex == FCurrentSession) &&
+    if (IsCurrentSessionSelected() &&
         (FAllowDirectCopy == drcConfirmCommandSession) &&
         !NotDirectCopyCheck->Checked &&
         GUIConfiguration->ConfirmCommandSession)
@@ -153,9 +156,14 @@ void __fastcall TRemoteTransferDialog::FormCloseQuery(TObject * /*Sender*/,
 void __fastcall TRemoteTransferDialog::NotDirectCopyCheckClick(
   TObject * /*Sender*/)
 {
-  if (SessionCombo->ItemIndex == FCurrentSession)
+  if (IsCurrentSessionSelected())
   {
     FDirectCopy = !NotDirectCopyCheck->Checked;
   }
 }
 //---------------------------------------------------------------------------
+bool __fastcall TRemoteTransferDialog::IsCurrentSessionSelected()
+{
+  return (SessionCombo->Items->Objects[SessionCombo->ItemIndex] == FCurrentSession);
+}
+//---------------------------------------------------------------------------

+ 4 - 2
source/forms/RemoteTransfer.h

@@ -34,16 +34,18 @@ public:
   __fastcall TRemoteTransferDialog(TComponent * Owner);
 
   void __fastcall Init(TStrings * Sessions, TStrings * Directories,
-    TDirectRemoteCopy AllowDirectCopy);
+    TDirectRemoteCopy AllowDirectCopy, void * CurrentSession);
   bool __fastcall Execute(void *& Session, UnicodeString & Target,
     UnicodeString & FileMask, bool & DirectCopy);
 
 protected:
   void __fastcall UpdateControls();
+  bool __fastcall IsCurrentSessionSelected();
+  void __fastcall UpdateNotDirectCopyCheck();
 
 private:
   TStrings * FDirectories;
-  int FCurrentSession;
+  void * FCurrentSession;
   bool FDirectCopy;
   TDirectRemoteCopy FAllowDirectCopy;
 };

+ 1 - 1
source/windows/WinInterface.h

@@ -288,7 +288,7 @@ bool __fastcall DoRemoteMoveDialog(UnicodeString & Target, UnicodeString & FileM
 enum TDirectRemoteCopy { drcDisallow, drcAllow, drcConfirmCommandSession };
 bool __fastcall DoRemoteCopyDialog(TStrings * Sessions, TStrings * Directories,
   TDirectRemoteCopy AllowDirectCopy, void *& Session, UnicodeString & Target, UnicodeString & FileMask,
-  bool & DirectCopy);
+  bool & DirectCopy, void * CurrentSession);
 
 // forms\SelectMask.cpp
 #ifdef CustomdirviewHPP