Browse Source

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
shortcuts
Matt Ward 17 years ago
parent
commit
52147675d7
  1. 17
      src/AddIns/Misc/HtmlHelp2/Project/src/Commands/ShowErrorHelpCommand.cs

17
src/AddIns/Misc/HtmlHelp2/Project/src/Commands/ShowErrorHelpCommand.cs

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision: 3555 $</version>
// </file>
using MSHelpServices;
using System;
using System.Collections.Generic;
@ -15,7 +16,7 @@ using ICSharpCode.SharpDevelop.Gui; @@ -15,7 +16,7 @@ using ICSharpCode.SharpDevelop.Gui;
namespace HtmlHelp2.Commands
{
/// <summary>
/// Description of ShowErrorHelpCommand
/// Shows help information for an error in the Errors window.
/// </summary>
public class ShowErrorHelpCommand : AbstractMenuCommand
{
@ -27,8 +28,7 @@ namespace HtmlHelp2.Commands @@ -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<Task>(view.SelectedTasks))
{
foreach (Task t in new List<Task>(view.SelectedTasks)) {
string code = t.BuildError.ErrorCode;
if (string.IsNullOrEmpty(code))
@ -38,8 +38,7 @@ namespace HtmlHelp2.Commands @@ -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 @@ -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 @@ -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;
}

Loading…
Cancel
Save