lcl: using process Executable instead of CommandLine

git-svn-id: trunk@51677 -
This commit is contained in:
mattias 2016-02-23 11:03:05 +00:00
parent dea4ec5cee
commit dabcac3009

View File

@ -19,7 +19,7 @@ interface
uses uses
Classes, SysUtils, LCLProc, LCLIntf, Forms, Process, LazFileUtils, UTF8Process, Classes, SysUtils, LCLProc, LCLIntf, Forms, Process, LazFileUtils, UTF8Process,
LazConfigStorage, LCLStrConsts, HelpIntfs, LazHelpIntf; LazConfigStorage, LazUTF8, LCLStrConsts, HelpIntfs, LazHelpIntf;
type type
{ THTMLHelpDatabase { THTMLHelpDatabase
@ -306,10 +306,9 @@ end;
function THTMLBrowserHelpViewer.ShowNode(Node: THelpNode; var ErrMsg: string function THTMLBrowserHelpViewer.ShowNode(Node: THelpNode; var ErrMsg: string
): TShowHelpResult; ): TShowHelpResult;
var var
Params: String;
URLMacroPos: LongInt; URLMacroPos: LongInt;
BrowserProcess: TProcessUTF8; BrowserProcess: TProcessUTF8;
CommandLine: String; Executable, ParamsStr: String;
begin begin
Result:=shrViewerError; Result:=shrViewerError;
ErrMsg:=''; ErrMsg:='';
@ -323,11 +322,11 @@ begin
end; end;
// check browser path // check browser path
CommandLine:=BrowserPath; Executable:=BrowserPath;
Params:=BrowserParams; ParamsStr:=BrowserParams;
if CommandLine='' then if Executable='' then
FindDefaultBrowser(CommandLine, Params); FindDefaultBrowser(Executable, ParamsStr);
if CommandLine='' then begin if Executable='' then begin
if (HelpDatabases<>nil) if (HelpDatabases<>nil)
and (CompareText(HelpDatabases.ClassName,'TIDEHelpDatabases')=0) then and (CompareText(HelpDatabases.ClassName,'TIDEHelpDatabases')=0) then
ErrMsg:=Format(hhsHelpNoHTMLBrowserFoundPleaseDefineOne,[LineEnding]) ErrMsg:=Format(hhsHelpNoHTMLBrowserFoundPleaseDefineOne,[LineEnding])
@ -335,31 +334,29 @@ begin
ErrMsg:=hhsHelpNoHTMLBrowserFound; ErrMsg:=hhsHelpNoHTMLBrowserFound;
exit; exit;
end; end;
if (not FileExistsUTF8(CommandLine)) then begin if (not FileExistsUTF8(Executable)) then begin
ErrMsg:=Format(hhsHelpBrowserNotFound, [CommandLine]); ErrMsg:=Format(hhsHelpBrowserNotFound, [Executable]);
exit; exit;
end; end;
if (not FileIsExecutable(CommandLine)) then begin if (not FileIsExecutable(Executable)) then begin
ErrMsg:=Format(hhsHelpBrowserNotExecutable, [CommandLine]); ErrMsg:=Format(hhsHelpBrowserNotExecutable, [Executable]);
exit; exit;
end; end;
//debugln('THTMLBrowserHelpViewer.ShowNode Node.URL=',Node.URL); //debugln('THTMLBrowserHelpViewer.ShowNode Node.URL=',Node.URL);
// create params and replace %s for URL // create params and replace %ParamsStr for URL
URLMacroPos:=Pos('%s',Params); URLMacroPos:=Pos('%s',ParamsStr);
if URLMacroPos>=1 then if URLMacroPos>=1 then
Params:=copy(Params,1,URLMacroPos-1)+Node.URL ReplaceSubstring(ParamsStr,URLMacroPos,2,Node.URL)
+copy(Params,URLMacroPos+2,length(Params)-URLMacroPos-1)
else begin else begin
if Params<>'' then if ParamsStr<>'' then
Params:=Params+' '; ParamsStr:=ParamsStr+' ';
Params:=Params+Node.URL; ParamsStr:=ParamsStr+Node.URL;
end; end;
CommandLine:=CommandLine+' '+Params;
{$IFNDEF DisableChecks} {$IFNDEF DisableChecks}
debugln('THTMLBrowserHelpViewer.ShowNode CommandLine=',CommandLine); debugln('THTMLBrowserHelpViewer.ShowNode Executable="',Executable,'" Params="',ParamsStr,'"');
{$ENDIF} {$ENDIF}
// run // run
@ -367,7 +364,8 @@ begin
BrowserProcess:=TProcessUTF8.Create(nil); BrowserProcess:=TProcessUTF8.Create(nil);
try try
BrowserProcess.InheritHandles:=false; BrowserProcess.InheritHandles:=false;
BrowserProcess.CommandLine:=CommandLine; BrowserProcess.Executable:=Executable;
SplitCmdLineParams(ParamsStr,BrowserProcess.Parameters);
BrowserProcess.Execute; BrowserProcess.Execute;
finally finally
BrowserProcess.Free; BrowserProcess.Free;
@ -375,7 +373,7 @@ begin
Result:=shrSuccess; Result:=shrSuccess;
except except
on E: Exception do begin on E: Exception do begin
ErrMsg:=Format(hhsHelpErrorWhileExecuting, [CommandLine, LineEnding, E.Message]); ErrMsg:=Format(hhsHelpErrorWhileExecuting, [Executable+' '+ParamsStr, LineEnding, E.Message]);
end; end;
end; end;
end; end;