IDE: fixed restart on darwin with lazarus.cfg

git-svn-id: trunk@64249 -
This commit is contained in:
mattias 2020-12-20 14:16:16 +00:00
parent a869c43f49
commit bd0a307669
3 changed files with 36 additions and 26 deletions

View File

@ -65,6 +65,7 @@ procedure ParseCommandLine(aCmdLineParams: TStrings; out IDEPid : Integer;
function GetCommandLineParameters(aCmdLineParams: TStrings;
isStartLazarus: Boolean = False) : string;
function ExtractPrimaryConfigPath(aCmdLineParams: TStrings): string;
function ExpandParamFile(const s: string): string;
function IsHelpRequested : Boolean;
function IsVersionRequested : boolean;
@ -282,6 +283,19 @@ begin
end;
end;
function ExpandParamFile(const s: string): string;
var
p: string;
begin
Result:=s;
for p in [PrimaryConfPathOptLong,SecondaryConfPathOptLong,LazarusDirOpt] do
if LeftStr(Result,length(p))=p then
begin
Result:=LeftStr(Result,length(p))+ExpandFileNameUTF8(copy(Result,length(p)+1,length(Result)));
exit;
end;
end;
function IsHelpRequested : Boolean;
var
i: integer;

View File

@ -483,6 +483,7 @@ begin
debugln(['Debug: (lazarus) ',aPID,' TIDEInstances.StartUserBuiltIDE FileAge: Custom=',CustomExe,':',FileAgeUTF8(CustomExe),' < Default=',DefaultExe,':',FileAgeUTF8(DefaultExe)]);
exit;
end;
//debugln(['Debug: (lazarus) ',aPID,' TIDEInstances.StartUserBuiltIDE FileAge: Custom=',CustomExe,':',FileAgeUTF8(CustomExe),' >= Default=',DefaultExe,':',FileAgeUTF8(DefaultExe)]);
if DirectoryIsWritable(DefaultDir) then
begin
@ -520,7 +521,7 @@ begin
{$ENDIF}
// append params, including the lazarus.cfg params
for i:=1 to CfgParams.Count-1 do
Params.Add(CfgParams[i]);
Params.Add(ExpandParamFile(CfgParams[i]));
aProcess.Parameters:=Params;
debugln(['Note: (lazarus) ',aPID,' TIDEInstances.StartUserBuiltIDE Starting custom IDE: aProcess.Executable=',aProcess.Executable,' Params=[',Params.Text,']']);
aProcess.Execute;

View File

@ -113,13 +113,13 @@ type
FProcess: TProcessUTF8;
FWantsRestart: boolean;
public
constructor Create(const LazarusPath: string; const CommandLine: string;
EnvOverrides: TStringList = nil);
constructor Create;
destructor Destroy; override;
procedure Execute;
procedure WaitOnExit;
property WantsRestart: boolean read FWantsRestart;
property OnStart: TNotifyEvent read FOnStart write FOnStart;
property Process: TProcessUTF8 read FProcess;
end;
type
@ -283,6 +283,8 @@ var
MsgResult: TModalResult;
StartPath: String;
EnvOverrides: TStringList;
Params: TStringListUTF8;
i: Integer;
begin
WaitForLazarus;
try
@ -380,10 +382,15 @@ begin
DebugLn(['Info: (startlazarus) [TLazarusManager.Run] starting ',FLazarusPath,' ...']);
EnvOverrides:=TStringList.Create;
Params:=TStringListUTF8.Create;
FLazarusProcess := TLazarusProcess.Create;
try
{$IFDEF Linux}
EnvOverrides.Values['LIBOVERLAY_SCROLLBAR']:='0';
{$ENDIF}
FLazarusProcess.Process.Executable:=fLazarusPath;
if (EnvOverrides<>nil) and (EnvOverrides.Count>0) then
AssignEnvironmentTo(FLazarusProcess.Process.Environment,EnvOverrides);
{$IFDEF darwin}
// "open" process runs a bundle, but doesn't wait for it to finish execution
// "startlazarus" logic suggests that the Lazarus process would be waited
@ -391,20 +398,18 @@ begin
// would repeat the restart process.
// Since "open" doesn't play nice with "startlazarus" logic.
// The arguments would not indicate that lazarus was started by startlazarus
FLazarusProcess :=
TLazarusProcess.Create('open',
' -a ' + FLazarusPath + ' --args'
+' '+NoSplashScreenOptLong
+' '+GetCommandLineParameters(FCmdLineParams, False)
+' '+FCmdLineFiles,
EnvOverrides);
{$ELSE}
FLazarusProcess :=
TLazarusProcess.Create(FLazarusPath,
GetCommandLineParameters(FCmdLineParams, True)+' '+FCmdLineFiles,
EnvOverrides);
FLazarusProcess.Process.Executable:='/usr/bin/open';
Params.Add('-a');
Params.Add(FLazarusPath);
Params.Add('--args');
{$ENDIF}
Params.Add(NoSplashScreenOptLong);
Params.Add(StartedByStartLazarusOpt);
for i:=0 to FCmdLineParams.Count-1 do
Params.Add(ExpandParamFile(FCmdLineParams[i]));
FLazarusProcess.Process.Parameters.AddStrings(Params);
finally
Params.Free;
EnvOverrides.Free;
end;
// clear the command line files, so that they are passed only once.
@ -432,22 +437,12 @@ end;
{ TLazarusProcess }
constructor TLazarusProcess.Create(const LazarusPath: string;
const CommandLine: string; EnvOverrides: TStringList);
var
Params: TStringListUTF8;
constructor TLazarusProcess.Create;
begin
FProcess := TProcessUTF8.Create(nil);
FProcess.InheritHandles := false;
FProcess.Options := [];
FProcess.ShowWindow := swoShow;
Params:=TStringListUTF8.Create;
SplitCmdLineParams(CommandLine,Params);
FProcess.Executable:=LazarusPath;
FProcess.Parameters:=Params;
Params.Free;
if (EnvOverrides<>nil) and (EnvOverrides.Count>0) then
AssignEnvironmentTo(FProcess.Environment,EnvOverrides);
end;
destructor TLazarusProcess.Destroy;