Browse Source

Issue 2284 – Copy and paste to another application sometimes does not work

https://winscp.net/tracker/2284
(cherry picked from commit b66e1cdb69840ed6b1e10aee5d9570c6768cd8cc)

# Conflicts:
#	source/forms/CustomScpExplorer.cpp

Source commit: 77b8daacedd0333c17df0c94017ec4f39e16a5cf
Martin Prikryl 1 năm trước cách đây
mục cha
commit
6dc180e5a5
1 tập tin đã thay đổi với 11 bổ sung1 xóa
  1. 11 1
      source/forms/CustomScpExplorer.cpp

+ 11 - 1
source/forms/CustomScpExplorer.cpp

@@ -11398,6 +11398,7 @@ void __fastcall TCustomScpExplorerForm::CopyFilesToClipboard(TOperationSide Side
     {
       FClipboardFileList->Strings[Index] = UnixExcludeTrailingBackslash(FClipboardFileList->Strings[Index]);
     }
+    AppLogFmt(L"Created fake clipboard directory \"%s\" and started drive monitors", (FClipboardFakeDirectory));
   }
 }
 //---------------------------------------------------------------------------
@@ -11465,13 +11466,19 @@ void TCustomScpExplorerForm::PasteFiles()
 
     try
     {
-      if (!NonVisualDataModule->Busy)
+      if (NonVisualDataModule->Busy)
+      {
+        AppLog(L"Is busy, cannot paste");
+      }
+      else
       {
         DebugAssert(!FClipboardFakeMonitorsPendingReset);
         FClipboardFakeMonitorsPendingReset = false;
         bool NoConfirmation = (WinConfiguration->DDTransferConfirmation == asOff);
         TAutoFlag Flag(FDownloadingFromClipboard);
+        AppLog(L"Downloading to paste target...");
         ClipboardDownload(ExtractFilePath(Target), NoConfirmation, true);
+        AppLog(L"Downloaded to paste target...");
       }
     }
     __finally
@@ -11490,6 +11497,9 @@ void __fastcall TCustomScpExplorerForm::ClipboardFakeCreated(TObject * /*Sender*
   // It can actually rarelly happen that some random file is created, while we are shutting down the monitor
   // (as it pumps a Windows message queue while being shutted down)
   if (DebugAlwaysTrue(!FClipboardFakeDirectory.IsEmpty()) &&
+      // Is can happen that creation of our temporary directory is detected (even though we are creating it before starting the monitors).
+      // It tent do happen with later copy-pastes, probably because everything is cached already and monitors start quickly.
+      !IsPathToSameFile(FClipboardFakeDirectory, FileName) &&
       SameText(ExtractFileName(FileName), ExtractFileName(FClipboardFakeDirectory)))
   {
     AppLogFmt(L"Fake clipboard directory pasted to \"%s\"", (FileName));