From 52147675d75526cc2d9de00014119faf418fc4fc Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Mon, 29 Dec 2008 13:20:33 +0000 Subject: [PATCH] Fixed ArgumentException when MSHelpServices GetSlotFromString method returns an invalid slot index. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3732 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../src/Commands/ShowErrorHelpCommand.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Commands/ShowErrorHelpCommand.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Commands/ShowErrorHelpCommand.cs index 80d6e86d4b..553d909ad8 100644 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Commands/ShowErrorHelpCommand.cs +++ b/src/AddIns/Misc/HtmlHelp2/Project/src/Commands/ShowErrorHelpCommand.cs @@ -4,6 +4,7 @@ // // $Revision: 3555 $ // + using MSHelpServices; using System; using System.Collections.Generic; @@ -15,7 +16,7 @@ using ICSharpCode.SharpDevelop.Gui; namespace HtmlHelp2.Commands { /// - /// Description of ShowErrorHelpCommand + /// Shows help information for an error in the Errors window. /// public class ShowErrorHelpCommand : AbstractMenuCommand { @@ -27,8 +28,7 @@ namespace HtmlHelp2.Commands ICSharpCode.SharpDevelop.Gui.TaskView view = (ICSharpCode.SharpDevelop.Gui.TaskView)Owner; // Search all selected tasks - foreach (Task t in new List(view.SelectedTasks)) - { + foreach (Task t in new List(view.SelectedTasks)) { string code = t.BuildError.ErrorCode; if (string.IsNullOrEmpty(code)) @@ -38,8 +38,7 @@ namespace HtmlHelp2.Commands MSHelpServices.IHxTopic topic; // If HtmlHelp2 AddIn is initialised correctly we can start! - if (HtmlHelp2.Environment.HtmlHelp2Environment.SessionIsInitialized) - { + if (HtmlHelp2.Environment.HtmlHelp2Environment.SessionIsInitialized) { // Get the topic IHxIndex index = HtmlHelp2.Environment.HtmlHelp2Environment.GetIndex(""); if (index == null) { @@ -47,6 +46,10 @@ namespace HtmlHelp2.Commands return; } int indexSlot = index.GetSlotFromString(code); + if (indexSlot <= 0) { + MessageService.ShowErrorFormatted("No help available for {0}!", code); + return; + } IHxTopicList list = index.GetTopicsFromSlot(indexSlot); if (list == null) { MessageService.ShowErrorFormatted("No help available for {0}!", code); @@ -62,9 +65,7 @@ namespace HtmlHelp2.Commands MessageService.ShowErrorFormatted("No help available for {0}!", code); return; } - } - else // Otherwise we have to show an Error message ... - { + } else { // Otherwise we have to show an Error message ... LoggingService.Error("Couldn't initialize help database"); return; }