Browse Source

Bug 1735: Cannot drag files from WinRAR

https://winscp.net/tracker/1735
(cherry picked from commit a2a5b6bd6bf60f9e858345976a01e6f1b0e35242)

Source commit: f1a9b91a866e2e063f20a766e830a60f8df86b42
Martin Prikryl 6 years ago
parent
commit
9818ff01a2

+ 6 - 1
source/packages/filemng/CustomDirView.pas

@@ -2069,7 +2069,12 @@ begin
      (Length(TFDDListItem(DragDropFilesEx.FileList[0]^).Name) > 0) and
      (not IsRecycleBin or not DragDropFilesEx.FileNamesAreMapped) then
   begin
-    FDragDrive := DriveInfo.GetDriveKey(TFDDListItem(DragDropFilesEx.FileList[0]^).Name);
+    try
+      FDragDrive := DriveInfo.GetDriveKey(TFDDListItem(DragDropFilesEx.FileList[0]^).Name);
+    except
+      // WinRAR gives us only filename on "enter", we get a full path only on "drop".
+      FDragDrive := '';
+    end;
     FExeDrag := FDDLinkOnExeDrag and
       (deLink in DragDropFilesEx.TargetEffects) and
       ((DragDropFilesEx.AvailableDropEffects and DROPEFFECT_LINK) <> 0);

+ 6 - 1
source/packages/filemng/CustomDriveView.pas

@@ -419,7 +419,12 @@ begin
   if (FDragDropFilesEx.FileList.Count > 0) and
      (Length(TFDDListItem(FDragDropFilesEx.FileList[0]^).Name) > 0) Then
   begin
-    FDragDrive := DriveInfo.GetDriveKey(TFDDListItem(FDragDropFilesEx.FileList[0]^).Name);
+    try
+      FDragDrive := DriveInfo.GetDriveKey(TFDDListItem(FDragDropFilesEx.FileList[0]^).Name);
+    except
+      // WinRAR gives us only filename on "enter", we get a full path only on "drop".
+      FDragDrive := '';
+    end;
     FExeDrag := FDDLinkOnExeDrag and
       (deLink in DragDropFilesEx.TargetEffects) and
       ((DragDropFilesEx.AvailableDropEffects and DROPEFFECT_LINK) <> 0);

+ 14 - 11
source/packages/filemng/DirView.pas

@@ -3143,19 +3143,22 @@ begin
     else
   if (grfKeyState and (MK_CONTROL or MK_SHIFT) = 0) then
   begin
-    if ExeDrag and DriveInfo.IsFixedDrive(DriveInfo.GetDriveKey(Path)) and DriveInfo.IsFixedDrive(FDragDrive) then
+    if FDragDrive <> '' then
     begin
-      dwEffect := DROPEFFECT_LINK
-    end
-      else
-    begin
-      if DragOnDriveIsMove and
-         (not DDOwnerIsSource or Assigned(DropTarget)) and
-         ((SameText(FDragDrive, DriveInfo.GetDriveKey(Path)) and (dwEffect = DROPEFFECT_COPY) and
-         (DragDropFilesEx.AvailableDropEffects and DROPEFFECT_MOVE <> 0))
-           or IsRecycleBin) then
+      if ExeDrag and DriveInfo.IsFixedDrive(DriveInfo.GetDriveKey(Path)) and DriveInfo.IsFixedDrive(FDragDrive) then
+      begin
+        dwEffect := DROPEFFECT_LINK;
+      end
+        else
       begin
-        dwEffect := DROPEFFECT_MOVE;
+        if DragOnDriveIsMove and
+           (not DDOwnerIsSource or Assigned(DropTarget)) and
+           ((SameText(FDragDrive, DriveInfo.GetDriveKey(Path)) and (dwEffect = DROPEFFECT_COPY) and
+           (DragDropFilesEx.AvailableDropEffects and DROPEFFECT_MOVE <> 0))
+             or IsRecycleBin) then
+        begin
+          dwEffect := DROPEFFECT_MOVE;
+        end;
       end;
     end;
   end;

+ 12 - 9
source/packages/filemng/DriveView.pas

@@ -2439,16 +2439,19 @@ begin
     else
   if (KeyState and (MK_CONTROL or MK_SHIFT) = 0) then
   begin
-    if FExeDrag and DriveInfo.IsFixedDrive(GetDriveToNode(DropTarget)) and DriveInfo.IsFixedDrive(FDragDrive) then
+    if FDragDrive <> '' then
     begin
-      Effect := DROPEFFECT_LINK;
-    end
-      else
-    if (Effect = DROPEFFECT_COPY) and
-       (SameText(FDragDrive, GetDriveToNode(DropTarget)) and
-         (FDragDropFilesEx.AvailableDropEffects and DROPEFFECT_MOVE <> 0)) then
-    begin
-      Effect := DROPEFFECT_MOVE;
+      if FExeDrag and DriveInfo.IsFixedDrive(GetDriveToNode(DropTarget)) and DriveInfo.IsFixedDrive(FDragDrive) then
+      begin
+        Effect := DROPEFFECT_LINK;
+      end
+        else
+      if (Effect = DROPEFFECT_COPY) and
+         (SameText(FDragDrive, GetDriveToNode(DropTarget)) and
+           (FDragDropFilesEx.AvailableDropEffects and DROPEFFECT_MOVE <> 0)) then
+      begin
+        Effect := DROPEFFECT_MOVE;
+      end;
     end;
   end;