mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
FIX: Bug [0000684] Drag&drop part of a file name when renaming file leads to ERR FILE NOT FOUND
This commit is contained in:
parent
869347e983
commit
28e23f31d4
6 changed files with 59 additions and 26 deletions
|
|
@ -404,7 +404,15 @@ begin
|
|||
except
|
||||
on EFileNotFound do
|
||||
if not OmitNotExisting then
|
||||
begin
|
||||
FreeAndNil(Result);
|
||||
raise;
|
||||
end;
|
||||
on Exception do
|
||||
begin
|
||||
FreeAndNil(Result);
|
||||
raise;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -342,8 +342,11 @@ type
|
|||
|
||||
EFileSourceException = class(Exception);
|
||||
EFileNotFound = class(EFileSourceException)
|
||||
private
|
||||
FFilePath: String;
|
||||
public
|
||||
constructor Create(const AFilePath: string); reintroduce;
|
||||
property FilePath: String read FFilePath;
|
||||
end;
|
||||
|
||||
var
|
||||
|
|
@ -352,7 +355,7 @@ var
|
|||
implementation
|
||||
|
||||
uses
|
||||
uDebug, uFileSourceListOperation;
|
||||
uDebug, uFileSourceListOperation, uLng;
|
||||
|
||||
{ TFileSource }
|
||||
|
||||
|
|
@ -904,7 +907,8 @@ end;
|
|||
|
||||
constructor EFileNotFound.Create(const AFilePath: string);
|
||||
begin
|
||||
inherited Create('File ' + aFilePath + ' not found.');
|
||||
FFilePath := AFilePath;
|
||||
inherited Create(Format(rsMsgFileNotFound, [aFilePath]));
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
|
|
|||
|
|
@ -158,8 +158,8 @@ uses
|
|||
Gtk2Proc, // for ReleaseMouseCapture
|
||||
GTK2Globals, // for DblClickTime
|
||||
{$ENDIF}
|
||||
LCLIntf, LCLProc, Forms,
|
||||
fMain, uShowMsg, uLng, uFileProperty, uFileSourceOperationTypes,
|
||||
LCLIntf, LCLProc, Forms, Dialogs,
|
||||
fMain, uShowMsg, uLng, uFileProperty, uFileSource, uFileSourceOperationTypes,
|
||||
uGlobs, uInfoToolTip, uDisplayFile, uFileSystemFileSource, uFileSourceUtil;
|
||||
|
||||
type
|
||||
|
|
@ -917,11 +917,12 @@ end;
|
|||
|
||||
function TFileViewWithMainCtrl.OnExDrop(const FileNamesList: TStringList; DropEffect: TDropEffect; ScreenPoint: TPoint): Boolean;
|
||||
var
|
||||
AFiles: TFiles;
|
||||
AFiles: TFiles = nil;
|
||||
DropParams: TDropParams;
|
||||
begin
|
||||
Result := False;
|
||||
if FileNamesList.Count > 0 then
|
||||
begin
|
||||
try
|
||||
AFiles := TFileSystemFileSource.CreateFilesFromFileList(
|
||||
ExtractFilePath(FileNamesList[0]), FileNamesList);
|
||||
try
|
||||
|
|
@ -930,14 +931,17 @@ begin
|
|||
nil, Self, Self.FileSource, Self.CurrentPath);
|
||||
|
||||
frmMain.DropFiles(DropParams);
|
||||
except
|
||||
|
||||
Result := True;
|
||||
finally
|
||||
FreeAndNil(AFiles);
|
||||
raise;
|
||||
end;
|
||||
except
|
||||
on e: EFileNotFound do
|
||||
MessageDlg(e.Message, mtError, [mbOK], 0);
|
||||
end;
|
||||
|
||||
SetDropFileIndex(-1);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TFileViewWithMainCtrl.SetDropFileIndex(NewFileIndex: PtrInt);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ object frmMain: TfrmMain
|
|||
OnCloseQuery = FormCloseQuery
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnDropFiles = FormDropFiles
|
||||
OnKeyDown = FormKeyDown
|
||||
OnKeyPress = FormKeyPress
|
||||
OnShow = frmMainShow
|
||||
|
|
|
|||
|
|
@ -777,6 +777,11 @@ begin
|
|||
Application.OnException := @AppException;
|
||||
Application.OnActivate := @AppActivate;
|
||||
|
||||
// Use LCL's method of dropping files from external
|
||||
// applications if we don't support it ourselves.
|
||||
if not IsExternalDraggingSupported then
|
||||
frmMain.OnDropFiles := @FormDropFiles;
|
||||
|
||||
{$IF DEFINED(DARWIN)}
|
||||
// MainForm receives in Mac OS closing events on system shortcut Command-Q
|
||||
// See details at http://doublecmd.sourceforge.net/mantisbt/view.php?id=712
|
||||
|
|
@ -1286,7 +1291,7 @@ end;
|
|||
|
||||
procedure TfrmMain.FormDropFiles(Sender: TObject; const FileNames: array of String);
|
||||
var
|
||||
TargetFileView: TFileView;
|
||||
TargetFileView: TFileView = nil;
|
||||
TargetControl: TControl;
|
||||
I: Integer;
|
||||
Files: TFiles = nil;
|
||||
|
|
@ -1294,8 +1299,6 @@ var
|
|||
Point: TPoint;
|
||||
DropParams: TDropParams;
|
||||
begin
|
||||
TargetFileView := nil;
|
||||
|
||||
TargetControl := FindLCLControl(Mouse.CursorPos);
|
||||
while TargetControl <> nil do
|
||||
begin
|
||||
|
|
@ -1320,22 +1323,35 @@ begin
|
|||
// fill file list by files
|
||||
FileNamesList := TStringList.Create;
|
||||
for I := Low(FileNames) to High(FileNames) do
|
||||
FileNamesList.Add(FileNames[I]);
|
||||
begin
|
||||
if Length(FileNames[I]) > 0 then
|
||||
FileNamesList.Add(FileNames[I]);
|
||||
end;
|
||||
|
||||
Files := TFileSystemFileSource.CreateFilesFromFileList(
|
||||
ExtractFilePath(FileNames[Low(FileNames)]), FileNamesList);
|
||||
if FileNamesList.Count > 0 then
|
||||
try
|
||||
Files := TFileSystemFileSource.CreateFilesFromFileList(
|
||||
ExtractFilePath(FileNamesList[0]), FileNamesList);
|
||||
|
||||
GetCursorPos(Point);
|
||||
if Files.Count > 0 then
|
||||
begin
|
||||
GetCursorPos(Point);
|
||||
|
||||
DropParams := TDropParams.Create(
|
||||
Files,
|
||||
GetDropEffectByKeyAndMouse(GetKeyShiftState, mbLeft),
|
||||
Point, False,
|
||||
nil, TargetFileView,
|
||||
TargetFileView.FileSource,
|
||||
TargetFileView.CurrentPath);
|
||||
DropParams := TDropParams.Create(
|
||||
Files,
|
||||
GetDropEffectByKeyAndMouse(GetKeyShiftState, mbLeft),
|
||||
Point, False,
|
||||
nil, TargetFileView,
|
||||
TargetFileView.FileSource,
|
||||
TargetFileView.CurrentPath);
|
||||
|
||||
DropFiles(DropParams);
|
||||
DropFiles(DropParams);
|
||||
end;
|
||||
|
||||
except
|
||||
on e: EFileNotFound do
|
||||
MessageDlg(e.Message, mtError, [mbOK], 0);
|
||||
end;
|
||||
|
||||
finally
|
||||
FreeAndNil(Files);
|
||||
|
|
|
|||
|
|
@ -29,8 +29,10 @@ interface
|
|||
uses
|
||||
LResources;
|
||||
resourcestring
|
||||
// File operations.
|
||||
rsMsgNotDelete = 'Can not delete file %s';
|
||||
rsMsgCannotDeleteDirectory = 'Cannot delete directory %s';
|
||||
rsMsgErrDirExists = 'Directory %s exists!';
|
||||
rsMsgErrRename = 'Cannot rename file %s to %s';
|
||||
rsMsgErrCannotCopyFile = 'Cannot copy file %s to %s';
|
||||
rsMsgFileExistsRwrt = 'File %s exists, overwrite?';
|
||||
|
|
@ -44,6 +46,7 @@ resourcestring
|
|||
rsMsgDelFlDrT = 'Delete %d selected files/directories into trash can?';
|
||||
rsMsgDelSelT = 'Delete selected "%s" into trash can?';
|
||||
rsMsgDelToTrashForce = 'Can not delete "%s" to trash! Delete directly?';
|
||||
rsMsgFileNotFound = 'File "%s" not found.';
|
||||
// ---
|
||||
rsMsgWipeFlDr = 'Wipe %d selected files/directories?';
|
||||
rsMsgWipeSel = 'Wipe selected "%s"?';
|
||||
|
|
@ -63,7 +66,6 @@ resourcestring
|
|||
rsMaskInput = 'Input mask:';
|
||||
rsFreeMsg = 'Free %s from %s bytes';
|
||||
rsFreeMsgShort = '%s bytes free';
|
||||
rsMsgErrDirExists = 'Directory %s exists!';
|
||||
rsMsgPopUpHotDelete = '&Delete %s';
|
||||
rsMsgDiskNotAvail = 'Disk is not available';
|
||||
rsMsgChDirFailed = 'ChDir to [%s] failed!';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue