From 830e082ffdd04f41197e40d852c02c96a664bd68 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 1 Aug 2008 13:21:57 -0400 Subject: [PATCH] Keep breakpoints in the preferences so they are restored at launch * Source/BreakpointManager.m+h: Add a savedBreakpoints ivar to hold the dictionarys (addBreakpoint:): Add the breakpoint to the NSUserDefaults (removeBreakpointAt:inFile:): Remove the breakpoint from NSUserDefaults --- CHANGES | 1 + Source/BreakpointManager.h | 1 + Source/BreakpointManager.m | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGES b/CHANGES index 6591159..8aa1a6c 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,7 @@ MacGDBp CHANGE LOG - New: Add menu items for the debugger commands - Fix: Several memory leaks that could, under certain conditions, would cause crashes (thanks to Ciarán Walsh) - Change: If MacGDBp can't highlight the source code, it will default to using just plain text +- New: Breakpoints are saved into preferences so that they are recreated at launch time 1.0.1 diff --git a/Source/BreakpointManager.h b/Source/BreakpointManager.h index dfb88f1..8976309 100644 --- a/Source/BreakpointManager.h +++ b/Source/BreakpointManager.h @@ -21,6 +21,7 @@ @interface BreakpointManager : NSObject { NSMutableArray *breakpoints; + NSMutableArray *savedBreakpoints; GDBpConnection *connection; } diff --git a/Source/BreakpointManager.m b/Source/BreakpointManager.m index 5a53155..12a7379 100644 --- a/Source/BreakpointManager.m +++ b/Source/BreakpointManager.m @@ -36,6 +36,15 @@ { breakpoints = [[NSMutableArray alloc] init]; } + + savedBreakpoints = [[[NSUserDefaults standardUserDefaults] mutableArrayValueForKey:@"Breakpoints"] retain]; + if (savedBreakpoints) + { + for (NSDictionary *d in savedBreakpoints) + { + [breakpoints addObject:[[[Breakpoint alloc] initWithDictionary:d] autorelease]]; + } + } } return self; } @@ -63,6 +72,9 @@ [breakpoints addObject:bp]; [connection addBreakpoint:bp]; + [savedBreakpoints addObject:[bp dictionary]]; + [[NSUserDefaults standardUserDefaults] setValue:savedBreakpoints forKey:@"Breakpoints"]; + [self updateDisplaysForFile:[bp file]]; } } @@ -78,6 +90,10 @@ { [breakpoints removeObject:b]; [connection removeBreakpoint:b]; + + [savedBreakpoints addObject:[b dictionary]]; + [[NSUserDefaults standardUserDefaults] setValue:savedBreakpoints forKey:@"Breakpoints"]; + [self updateDisplaysForFile:file]; return b; } -- 2.43.5