chmhelp: fixed crash when lhelp is not there and give a hint what to do

git-svn-id: trunk@40590 -
This commit is contained in:
mattias 2013-03-19 09:14:39 +00:00
parent f3776676a3
commit 36a7559b8c
2 changed files with 26 additions and 13 deletions

View File

@ -23,9 +23,17 @@ interface
uses uses
Classes, SysUtils, FileUtil, LazLogger, LazFileUtils, LazHelpIntf, HelpIntfs, Classes, SysUtils, FileUtil, LazLogger, LazFileUtils, LazHelpIntf, HelpIntfs,
LazConfigStorage, PropEdits, LazIDEIntf, LHelpControl, Controls, UTF8Process, LazConfigStorage, PropEdits, LazIDEIntf, IDEDialogs, LHelpControl, Controls,
ChmLangRef, ChmLcl, ChmProg; UTF8Process, ChmLangRef, ChmLcl, ChmProg;
resourcestring
HELP_CURRENT_MENU = '&Help';
HELP_CURRENT_IDECMD = 'Show help';
HELP_CATEGORY_IDECMD = 'CHM Help';
HELP_MissingLhelp = 'Missing lhelp';
HELP_UnableToFindTheLhelpViewerPleaseCompileTheLhelpPro = 'Unable to find '
+'the lhelp viewer:%s%s%s%sPlease compile the lhelp project:%s%s';
type type
{ TChmHelpViewer } { TChmHelpViewer }
@ -74,7 +82,7 @@ type
property HelpExeParams: String read fHelpExeParams write fHelpExeParams; property HelpExeParams: String read fHelpExeParams write fHelpExeParams;
end; end;
procedure Register; procedure Register;
implementation implementation
@ -411,11 +419,24 @@ end;
procedure TChmHelpViewer.ShowAllHelp(Sender: TObject); procedure TChmHelpViewer.ShowAllHelp(Sender: TObject);
var var
SearchPath: String; //; delimited list of directories SearchPath: String; //; delimited list of directories
LHelpFilename: String;
begin begin
SearchPath := GetHelpFilesPath; SearchPath := GetHelpFilesPath;
// Start up server if needed // Start up server if needed
if not(fHelpConnection.ServerRunning) then if not(fHelpConnection.ServerRunning) then
fHelpConnection.StartHelpServer(HelpLabel, GetHelpExe); begin
LHelpFilename:=GetHelpExe;
if not FileExistsUTF8(LHelpFilename) then
begin
IDEMessageDialog(HELP_MissingLhelp, Format(
HELP_UnableToFindTheLhelpViewerPleaseCompileTheLhelpPro,
[#13, LHelpFilename, #13, #13, #13,
SetDirSeparators('components/chmhelp/lhelp/lhelp.lpi')]),
mtError,[mbCancel]);
exit;
end;
fHelpConnection.StartHelpServer(HelpLabel, LHelpFilename);
end;
// Open all chm files after it has started // Open all chm files after it has started
OpenAllCHMsInSearchPath(SearchPath); OpenAllCHMsInSearchPath(SearchPath);
end; end;

View File

@ -39,17 +39,9 @@ uses
LazCHMHelp, InterfaceBase, IDEMsgIntf; LazCHMHelp, InterfaceBase, IDEMsgIntf;
const const
//HELP_MENU_NAME = 'chpOfflineHelp';
HELP_CURRENT_NAME = 'chpHelp'; HELP_CURRENT_NAME = 'chpHelp';
HELP_CATEGORY_IDECMD_NAME = 'chpFormat'; HELP_CATEGORY_IDECMD_NAME = 'chpFormat';
resourcestring
//HELP_MENU = '&Help';
HELP_CURRENT_MENU = '&Help';
HELP_CURRENT_IDECMD = 'Show help';
HELP_CATEGORY_IDECMD = 'CHM Help';
var var
IDECHMHelp: TChmHelpViewer; IDECHMHelp: TChmHelpViewer;
@ -83,4 +75,4 @@ end;
finalization finalization
FreeAndNil(IDECHMHelp); FreeAndNil(IDECHMHelp);
end. end.