From ad1f5c90171b794a6babc00b31ef9655ce5c5f93 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 8 Dec 2019 00:04:14 -0500 Subject: [PATCH] The BreakpointManager does not need to know about the UI. --- Source/BreakpointController.m | 14 +++++++----- Source/BreakpointManager.m | 40 +++++++---------------------------- 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/Source/BreakpointController.m b/Source/BreakpointController.m index 516f3a9..362d3b8 100644 --- a/Source/BreakpointController.m +++ b/Source/BreakpointController.m @@ -85,12 +85,16 @@ { NSArray* selection = [_arrayController selectedObjects]; if ([selection count] < 1) - { return; - } - - for (Breakpoint* bp in selection) { - [_manager removeBreakpoint:bp]; + + Breakpoint* bp = [selection firstObject]; + [_manager removeBreakpoint:bp]; + + if (bp.type == kBreakpointTypeFile && [_sourceView.file isEqualToString:bp.file]) { + NSSet* markers = [_sourceView.markers objectsPassingTest:^BOOL(NSNumber* obj, BOOL* stop) { + return obj.unsignedLongValue != bp.line; + }]; + [_sourceView setMarkers:markers]; } } diff --git a/Source/BreakpointManager.m b/Source/BreakpointManager.m index bc4b216..b58c4ed 100644 --- a/Source/BreakpointManager.m +++ b/Source/BreakpointManager.m @@ -16,13 +16,8 @@ #import "BreakpointManager.h" -#import "AppDelegate.h" #import "PreferenceNames.h" -@interface BreakpointManager (Private) -- (void)updateDisplaysForFile:(NSString*)file; -@end - @implementation BreakpointManager { NSMutableArray* _breakpoints; NSMutableArray* _savedBreakpoints; @@ -54,19 +49,17 @@ */ - (void)addBreakpoint:(Breakpoint*)bp; { - if (![_breakpoints containsObject:bp]) - { - [self willChangeValueForKey:@"breakpoints"]; - [_breakpoints addObject:bp]; - [self didChangeValueForKey:@"breakpoints"]; + if ([_breakpoints containsObject:bp]) + return; - [_connection addBreakpoint:bp]; + [self willChangeValueForKey:@"breakpoints"]; + [_breakpoints addObject:bp]; + [self didChangeValueForKey:@"breakpoints"]; - [_savedBreakpoints addObject:[bp dictionary]]; - [[NSUserDefaults standardUserDefaults] setObject:_savedBreakpoints forKey:kPrefBreakpoints]; + [_connection addBreakpoint:bp]; - [self updateDisplaysForFile:[bp file]]; - } + [_savedBreakpoints addObject:[bp dictionary]]; + [[NSUserDefaults standardUserDefaults] setObject:_savedBreakpoints forKey:kPrefBreakpoints]; } - (Breakpoint*)removeBreakpoint:(Breakpoint*)bp @@ -88,9 +81,6 @@ [_savedBreakpoints removeObject:[bp dictionary]]; [[NSUserDefaults standardUserDefaults] setObject:_savedBreakpoints forKey:kPrefBreakpoints]; - if (bp.file) - [self updateDisplaysForFile:bp.file]; - return bp; } @@ -115,18 +105,4 @@ return [_breakpoints containsObject:breakpoint]; } -#pragma mark Private - -/** - * This marks BSSourceView needsDisplay, rearranges the objects in the breakpoints controller, - * and sets the markers for the BSLineNumberView - */ -- (void)updateDisplaysForFile:(NSString*)file -{ - AppDelegate* appDel = [NSApp delegate]; - [[[appDel breakpoint] arrayController] rearrangeObjects]; - [[[appDel debugger] sourceViewer] setNeedsDisplay:YES]; - [[[appDel debugger] sourceViewer] setMarkers:[self breakpointsForFile:file]]; -} - @end -- 2.43.5