From 5869e66a6e2bb06c52d21c67c02554e41f86cbac Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 5 Jul 2008 15:41:17 +0000 Subject: [PATCH] Fixed an InvalidOperationException when a breakpoint bookmark was removed via the Toggle Breakpoint menu item. The command was removing a bookmark whilst the enumerator was still active. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3174 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Base/Project/Src/Services/Debugger/DebuggerService.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 8e417d563a..6d1d1a7303 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Text; using System.Windows.Forms; @@ -219,11 +220,12 @@ namespace ICSharpCode.SharpDevelop.Debugging public static void ToggleBreakpointAt(IDocument document, string fileName, int lineNumber) { - foreach (Bookmark m in document.BookmarkManager.Marks) { - BreakpointBookmark breakpoint = m as BreakpointBookmark; + ReadOnlyCollection bookmarks = document.BookmarkManager.Marks; + for (int i = bookmarks.Count - 1; i >= 0; --i) { + BreakpointBookmark breakpoint = bookmarks[i] as BreakpointBookmark; if (breakpoint != null) { if (breakpoint.LineNumber == lineNumber) { - document.BookmarkManager.RemoveMark(m); + document.BookmarkManager.RemoveMark(breakpoint); return; } }