mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 04:35:57 +02:00
startlazarus: fixed passing files, issue #40044
This commit is contained in:
parent
659f556800
commit
c4da2ae1aa
@ -132,7 +132,7 @@ type
|
|||||||
FLazarusPath: string;
|
FLazarusPath: string;
|
||||||
FLazarusPID: Integer;
|
FLazarusPID: Integer;
|
||||||
FCmdLineParams: TStrings;
|
FCmdLineParams: TStrings;
|
||||||
FCmdLineFiles: string;
|
FCmdLineFiles: TStrings;
|
||||||
FShowSplashOption: boolean;
|
FShowSplashOption: boolean;
|
||||||
function RenameLazarusExecutable(const Directory: string): TModalResult;
|
function RenameLazarusExecutable(const Directory: string): TModalResult;
|
||||||
procedure LazarusProcessStart(Sender: TObject);
|
procedure LazarusProcessStart(Sender: TObject);
|
||||||
@ -150,6 +150,7 @@ implementation
|
|||||||
destructor TLazarusManager.Destroy;
|
destructor TLazarusManager.Destroy;
|
||||||
begin
|
begin
|
||||||
FreeAndNil(FCmdLineParams);
|
FreeAndNil(FCmdLineParams);
|
||||||
|
FreeAndNil(FCmdLineFiles);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -239,7 +240,7 @@ end;
|
|||||||
|
|
||||||
procedure TLazarusManager.Initialize;
|
procedure TLazarusManager.Initialize;
|
||||||
var
|
var
|
||||||
CmdLineFiles: TStrings;
|
Files: TStrings;
|
||||||
i: integer;
|
i: integer;
|
||||||
PCP: String;
|
PCP: String;
|
||||||
begin
|
begin
|
||||||
@ -262,14 +263,12 @@ begin
|
|||||||
SetPrimaryConfigPath(PCP);
|
SetPrimaryConfigPath(PCP);
|
||||||
|
|
||||||
// get command line files
|
// get command line files
|
||||||
CmdLineFiles := LazIDEInstances.FilesToOpen;
|
Files := LazIDEInstances.FilesToOpen;
|
||||||
if CmdLineFiles<>nil then
|
FCmdLineFiles := TStringListUTF8Fast.Create;
|
||||||
|
if Files<>nil then
|
||||||
begin
|
begin
|
||||||
for i := 0 to CmdLineFiles.Count-1 do
|
for i := 0 to Files.Count-1 do
|
||||||
if pos(' ',CmdLineFiles[i])>0 then
|
FCmdLineFiles.Add(Files[i]);
|
||||||
CmdLineFiles[i] := '"' + CmdLineFiles[i] + '"';
|
|
||||||
CmdLineFiles.Delimiter:=' ';
|
|
||||||
FCmdLineFiles:=CmdLineFiles.DelimitedText;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -406,23 +405,25 @@ begin
|
|||||||
Params.Add(FLazarusPath);
|
Params.Add(FLazarusPath);
|
||||||
Params.Add('--args');
|
Params.Add('--args');
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
// tell lazarus, startlazarus is waiting for its exitcode
|
// tell lazarus that startlazarus is waiting for its exitcode
|
||||||
// When the special 99 (ExitCodeRestartLazarus) code is received,
|
// When the special 99 (ExitCodeRestartLazarus) code is received,
|
||||||
// start a new lazars
|
// start a new lazarus
|
||||||
Params.Add(StartedByStartLazarusOpt);
|
Params.Add(StartedByStartLazarusOpt);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Params.Add(NoSplashScreenOptLong);
|
Params.Add(NoSplashScreenOptLong);
|
||||||
for i:=0 to FCmdLineParams.Count-1 do
|
for i:=0 to FCmdLineParams.Count-1 do
|
||||||
AddExpandedParam(Params,FCmdLineParams[i]);
|
AddExpandedParam(Params,FCmdLineParams[i]);
|
||||||
|
for i:=0 to FCmdLineFiles.Count-1 do
|
||||||
|
Params.Add(ExpandFileNameUTF8(FCmdLineFiles[i]));
|
||||||
FLazarusProcess.Process.Parameters.AddStrings(Params);
|
FLazarusProcess.Process.Parameters.AddStrings(Params);
|
||||||
finally
|
finally
|
||||||
Params.Free;
|
Params.Free;
|
||||||
EnvOverrides.Free;
|
EnvOverrides.Free;
|
||||||
end;
|
end;
|
||||||
// clear the command line files, so that they are passed only once.
|
// clear the command line files, so that they are passed only once.
|
||||||
FCmdLineFiles:='';
|
FCmdLineFiles.Clear;
|
||||||
FLazarusProcess.OnStart := @LazarusProcessStart;
|
FLazarusProcess.OnStart := @LazarusProcessStart;
|
||||||
DebugLn(['Info: (startlazarus) [TLazarusManager.Run] exe',FLazarusProcess.Process.Executable,' Params=[',FLazarusProcess.Process.Parameters.Text,']']);
|
DebugLn(['Info: (startlazarus) [TLazarusManager.Run] exe=',FLazarusProcess.Process.Executable,' Params=[',FLazarusProcess.Process.Parameters.Text,']']);
|
||||||
FLazarusProcess.Execute;
|
FLazarusProcess.Execute;
|
||||||
{$IFDEF darwin}
|
{$IFDEF darwin}
|
||||||
Restart:=false;
|
Restart:=false;
|
||||||
|
Loading…
Reference in New Issue
Block a user