瀏覽代碼

Bug fix: Failure when coping local custom command that works with remote files to clipboard

Source commit: 986add2cb8bf6183bec04f1cdec8883dd8c964a3
Martin Prikryl 8 年之前
父節點
當前提交
c872a68bc6
共有 1 個文件被更改,包括 24 次插入14 次删除
  1. 24 14
      source/windows/GUITools.cpp

+ 24 - 14
source/windows/GUITools.cpp

@@ -218,7 +218,14 @@ static bool __fastcall DoExecuteShell(const UnicodeString Path, const UnicodeStr
 {
   bool Result = CopyCommandToClipboard(FormatCommand(Path, Params));
 
-  if (!Result)
+  if (Result)
+  {
+    if (Handle != NULL)
+    {
+      *Handle = NULL;
+    }
+  }
+  else
   {
     UnicodeString Directory = ExtractFilePath(Path);
 
@@ -280,24 +287,27 @@ void __fastcall ExecuteShellCheckedAndWait(const UnicodeString Command,
   }
   else
   {
-    if (ProcessMessages != NULL)
+    if (ProcessHandle != NULL) // only if command was copied to clipboard only
     {
-      unsigned long WaitResult;
-      do
+      if (ProcessMessages != NULL)
       {
-        // Same as in ExecuteProcessAndReadOutput
-        WaitResult = WaitForSingleObject(ProcessHandle, 200);
-        if (WaitResult == WAIT_FAILED)
+        unsigned long WaitResult;
+        do
         {
-          throw Exception(LoadStr(DOCUMENT_WAIT_ERROR));
+          // Same as in ExecuteProcessAndReadOutput
+          WaitResult = WaitForSingleObject(ProcessHandle, 200);
+          if (WaitResult == WAIT_FAILED)
+          {
+            throw Exception(LoadStr(DOCUMENT_WAIT_ERROR));
+          }
+          ProcessMessages();
         }
-        ProcessMessages();
+        while (WaitResult == WAIT_TIMEOUT);
+      }
+      else
+      {
+        WaitForSingleObject(ProcessHandle, INFINITE);
       }
-      while (WaitResult == WAIT_TIMEOUT);
-    }
-    else
-    {
-      WaitForSingleObject(ProcessHandle, INFINITE);
     }
   }
 }