From 8550bd18d28e55c54d9c21180e7bd2d004a65e9b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 2 Dec 2015 08:23:18 -0500 Subject: [PATCH] Remove -[DebuggerBackEndDelegate sourceUpdated:]. Use KVO to call -[DebuggerController updateSourceViewer] instead. --- Source/DebuggerBackEnd.h | 4 ---- Source/DebuggerBackEnd.m | 2 -- Source/DebuggerController.m | 14 ++++++-------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Source/DebuggerBackEnd.h b/Source/DebuggerBackEnd.h index 08bdf0b..135e572 100644 --- a/Source/DebuggerBackEnd.h +++ b/Source/DebuggerBackEnd.h @@ -91,9 +91,5 @@ // Called when we disconnect. - (void)debuggerDisconnected; -// Tells the debugger that new source is available for the given frame. -// TODO: rename to |-frameUpdated:|. -- (void)sourceUpdated:(StackFrame*)frame; - @end diff --git a/Source/DebuggerBackEnd.m b/Source/DebuggerBackEnd.m index f9f64cd..e672e95 100644 --- a/Source/DebuggerBackEnd.m +++ b/Source/DebuggerBackEnd.m @@ -157,8 +157,6 @@ if ([frame.filename length]) { ProtocolClientMessageHandler handler = ^(NSXMLDocument* message) { frame.source = [[message rootElement] base64DecodedValue]; - if ([self.delegate respondsToSelector:@selector(sourceUpdated:)]) - [self.delegate sourceUpdated:frame]; }; [_client sendCommandWithFormat:@"source -f %@" handler:handler, frame.filename]; } diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index c97dcc1..7bcf520 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -81,6 +81,10 @@ forKeyPath:@"selectedObjects" options:NSKeyValueObservingOptionNew context:nil]; + [stackArrayController addObserver:self + forKeyPath:@"selection.source" + options:NSKeyValueObservingOptionNew + context:nil]; self.connection.autoAttach = [attachedCheckbox_ state] == NSOnState; } @@ -94,6 +98,8 @@ if (object == stackArrayController && [keyPath isEqualToString:@"selectedObjects"]) { for (StackFrame* frame in stackArrayController.selectedObjects) [connection loadStackFrame:frame]; + } else if (object == stackArrayController && [keyPath isEqualToString:@"selection.source"]) { + [self updateSourceViewer]; } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } @@ -249,7 +255,6 @@ */ - (void)tableViewSelectionDidChange:(NSNotification*)notif { - [self updateSourceViewer]; // TODO: This is very, very hacky because it's nondeterministic. The issue // is that calling |-[NSOutlineView expandItem:]| while the table is still // doing its redraw will translate to a no-op. Instead, we need to restructure @@ -367,11 +372,4 @@ [sourceViewer setNeedsDisplay:YES]; } -#pragma mark GDBpConnectionDelegate - -- (void)sourceUpdated:(StackFrame*)frame -{ - [self updateSourceViewer]; -} - @end -- 2.43.5