diff --git a/components/chmhelp/packages/help/lazhelpchm.pas b/components/chmhelp/packages/help/lazhelpchm.pas index 81df350068..809d5224f5 100644 --- a/components/chmhelp/packages/help/lazhelpchm.pas +++ b/components/chmhelp/packages/help/lazhelpchm.pas @@ -162,11 +162,15 @@ begin end; SplitURL(Node.URL,URLScheme,URLPath,URLParams); - CHMFilename:=SetDirSeparators(URLPath); + CHMFilename:=CleanAndExpandFilename(URLPath); if not FileExistsUTF8(CHMFilename) then begin ErrMsg:='chm file "'+CHMFilename+'" not found'; exit; end; + if DirPathExists(CHMFilename) then begin + ErrMsg:='invalid chm file "'+CHMFilename+'"'; + exit; + end; SubPath:=''; if (URLParams<>'') and (URLParams[1]='?') then @@ -205,12 +209,6 @@ begin if s<>'' then Path:=s; end; - {$IFDEF darwin} - // search exe in application bundle - if DirectoryExistsUTF8(Path+'.app') then - Path:=Path+'.app/Contents/MacOS/'+ExtractFileName(Path); - {$ENDIF} - if not FileExistsUTF8(Path) then begin ErrMsg:='The chm viewer program lhelp was not found at "'+Path+'"'; exit; @@ -231,6 +229,7 @@ begin else ErrMsg:='Something is wrong with lhelp'; end; + debugln(['TLHelpConnector.ShowNode error: ',ErrMsg]); end; procedure TLHelpConnector.Assign(Source: TPersistent); diff --git a/components/chmhelp/packages/help/lhelpcontrol.pas b/components/chmhelp/packages/help/lhelpcontrol.pas index c03e1066dd..1476365851 100644 --- a/components/chmhelp/packages/help/lhelpcontrol.pas +++ b/components/chmhelp/packages/help/lhelpcontrol.pas @@ -23,7 +23,7 @@ uses {$IFDEF STALE_PIPE_WORKAROUND} BaseUnix, {$ENDIF} - Classes, SysUtils, FileUtil, SimpleIPC, UTF8Process; + Classes, SysUtils, FileUtil, LazLogger, SimpleIPC, process, UTF8Process; type TRequestType = (rtFile, rtUrl, rtContext); @@ -172,6 +172,7 @@ function TLHelpConnection.StartHelpServer(NameForServer: String; ServerEXE: String): Boolean; var X: Integer; + Cmd: String; begin Result := False; @@ -183,8 +184,21 @@ begin fServerOut.Active := False; fServerOut.ServerID := NameForServer; if not ServerRunning then begin + Cmd:= ServerExe + ' --ipcname ' + NameForServer; + {$IFDEF darwin} + if DirectoryExistsUTF8(ServerEXE+'.app') then + ServerEXE+='.app'; + debugln(['TLHelpConnection.StartHelpServer ',ServerEXE]); + if DirectoryExistsUTF8(ServerEXE) then begin + // application bundle + // to put lhelp into the foreground, use "open -n" + Cmd:='/usr/bin/open -n '+ServerEXE+' --args --ipcname ' + NameForServer + end; + DebugLn(['TLHelpConnection.StartHelpServer ',cmd]); + {$ENDIF} with TProcessUTF8.Create(nil) do begin - CommandLine := ServerExe + ' --ipcname ' + NameForServer; + ShowWindow:=swoShowNormal; + CommandLine := Cmd; Execute; Free; end;