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
Classes, SysUtils, FileUtil, LazLogger, LazFileUtils, LazHelpIntf, HelpIntfs,
LazConfigStorage, PropEdits, LazIDEIntf, LHelpControl, Controls, UTF8Process,
ChmLangRef, ChmLcl, ChmProg;
LazConfigStorage, PropEdits, LazIDEIntf, IDEDialogs, LHelpControl, Controls,
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
{ TChmHelpViewer }
@ -74,7 +82,7 @@ type
property HelpExeParams: String read fHelpExeParams write fHelpExeParams;
end;
procedure Register;
procedure Register;
implementation
@ -411,11 +419,24 @@ end;
procedure TChmHelpViewer.ShowAllHelp(Sender: TObject);
var
SearchPath: String; //; delimited list of directories
LHelpFilename: String;
begin
SearchPath := GetHelpFilesPath;
// Start up server if needed
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
OpenAllCHMsInSearchPath(SearchPath);
end;

View File

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