From da1e96242d50bd59086b432df4b013dbeea10cba Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 24 Oct 2015 01:49:16 -0400 Subject: [PATCH] Ensure that stack frames are loaded when the array controller selection changes. This also makes the array controller not attempt to preserve the selection. --- English.lproj/Debugger.xib | 2 +- Source/DebuggerController.m | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/English.lproj/Debugger.xib b/English.lproj/Debugger.xib index 1d2a263..6175676 100644 --- a/English.lproj/Debugger.xib +++ b/English.lproj/Debugger.xib @@ -388,7 +388,7 @@ - + filename index diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index c15befd..9de5466 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -76,10 +76,29 @@ [[self window] setExcludedFromWindowsMenu:YES]; [[self window] setTitle:[NSString stringWithFormat:@"MacGDBp @ %d", [connection port]]]; [sourceViewer setDelegate:self]; - [stackArrayController setSortDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"index" ascending:YES] autorelease]]]; + [stackArrayController setSortDescriptors:@[ [[[NSSortDescriptor alloc] initWithKey:@"index" ascending:YES] autorelease] ]]; + [stackArrayController addObserver:self + forKeyPath:@"selectedObjects" + options:NSKeyValueObservingOptionNew + context:nil]; self.connection.autoAttach = [attachedCheckbox_ state] == NSOnState; } +/** + * Key-value observation routine. + */ +- (void)observeValueForKeyPath:(NSString*)keyPath + ofObject:(id)object + change:(NSDictionary*)change + context:(void*)context { + if (object == stackArrayController && [keyPath isEqualToString:@"selectedObjects"]) { + for (StackFrame* frame in stackArrayController.selectedObjects) + [connection loadStackFrame:frame]; + } else { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } +} + /** * Validates the menu items for the "Debugger" menu */ -- 2.43.5