From c480f715d412a20d0bb613b6f38a9f024b760f46 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 7 Dec 2015 00:46:08 -0500 Subject: [PATCH] Remove -[DebuggerBackEndDelegate errorEncountered:]. Error information is now bound via the model. --- English.lproj/Debugger.xib | 9 ++++++++- Source/DebuggerBackEnd.h | 4 ---- Source/DebuggerBackEnd.m | 8 +++----- Source/DebuggerController.m | 8 -------- Source/DebuggerModel.h | 11 +++++++++++ Source/DebuggerModel.m | 5 +++++ 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/English.lproj/Debugger.xib b/English.lproj/Debugger.xib index a8174ca..512f170 100644 --- a/English.lproj/Debugger.xib +++ b/English.lproj/Debugger.xib @@ -8,7 +8,6 @@ - @@ -39,6 +38,14 @@ + + + + NSIsNotNil + + + + diff --git a/Source/DebuggerBackEnd.h b/Source/DebuggerBackEnd.h index 135e572..6fa17b2 100644 --- a/Source/DebuggerBackEnd.h +++ b/Source/DebuggerBackEnd.h @@ -81,10 +81,6 @@ @protocol DebuggerBackEndDelegate -// Passes up errors from SocketWrapper and any other errors generated by the -// GDBpConnection. -- (void)errorEncountered:(NSString*)error; - // Called when the socket connects. Passed up from SocketWrapper. - (void)debuggerConnected; diff --git a/Source/DebuggerBackEnd.m b/Source/DebuggerBackEnd.m index e672e95..1c5359c 100644 --- a/Source/DebuggerBackEnd.m +++ b/Source/DebuggerBackEnd.m @@ -276,6 +276,8 @@ if ([self.delegate respondsToSelector:@selector(debuggerDisconnected)]) [self.delegate debuggerDisconnected]; + [_model onDisconnect]; + if (self.autoAttach) [_client connectOnPort:_port]; } @@ -289,17 +291,13 @@ if ([error count] > 0) { NSLog(@"Xdebug error: %@", error); NSString* errorMessage = [[[[error objectAtIndex:0] children] objectAtIndex:0] stringValue]; - [self errorEncountered:errorMessage]; + _model.lastError = errorMessage; } } // Specific Response Handlers ////////////////////////////////////////////////// #pragma mark Response Handlers -- (void)errorEncountered:(NSString*)error { - [self.delegate errorEncountered:error]; -} - /** * Initial packet received. We've started a brand-new connection to the engine. */ diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index 7bcf520..e47846a 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -165,14 +165,6 @@ [errormsg setHidden:NO]; } -/** - * Handles a GDBpConnection error - */ -- (void)errorEncountered:(NSString*)error -{ - [self setError:error]; -} - /** * Delegate function for GDBpConnection for when the debugger connects. */ diff --git a/Source/DebuggerModel.h b/Source/DebuggerModel.h index 5b8e4a2..82ccb4d 100644 --- a/Source/DebuggerModel.h +++ b/Source/DebuggerModel.h @@ -20,18 +20,29 @@ @interface DebuggerModel : NSObject +// Whether or not the debugger is currently connected. +@property(readonly, nonatomic) BOOL connected; + // A human-readable representation of the debugger state. E.g., "Break" or // "Stopped". @property(copy, nonatomic) NSString* status; +// A string representing the last error message, or nil for no error. +@property(copy, nonatomic) NSString* lastError; + +// An array of StackFrame objects for the current call stack. @property(readonly, nonatomic) NSArray* stack; +// Helper accessor for |stack.count|. @property(readonly, nonatomic) NSUInteger stackDepth; // Informs the model that a new connection was initiated. This clears any data // in the model. - (void)onNewConnection; +// Informs the model that the connection was terminated. +- (void)onDisconnect; + // Replaces the current stack with |newStack|. This will attempt to preserve // any already loaded frames. - (void)updateStack:(NSArray*)newStack; diff --git a/Source/DebuggerModel.m b/Source/DebuggerModel.m index b3a2c5b..89adb43 100644 --- a/Source/DebuggerModel.m +++ b/Source/DebuggerModel.m @@ -41,9 +41,14 @@ - (void)onNewConnection { self.status = nil; + _connected = YES; [_stack removeAllObjects]; } +- (void)onDisconnect { + _connected = NO; +} + - (void)updateStack:(NSArray*)newStack { // Iterate, in reverse order from the bottom to the top, both stacks to find // the point of divergence. -- 2.22.5