From d9ebad6d24409d279b9daaf40e5e7e2e80fbd6b3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 30 Nov 2008 23:06:34 -0500 Subject: [PATCH] Rather than having GDBpConnection tell the window controller to change status, cache the status as an ivar and bind to it * Source/GDBpConnection.h: Define the status ivar and make it a prop * Source/GDBpConnection.m: (refreshStatus): Remove most of the status-updating code (updateStatus): New method to fetch and set the status ivar * English.lproj/Debugger.xib: Bind the status text to GDBpConnection's new status ivar --- English.lproj/Debugger.xib | 30 +++++++++++++++++++++-------- Source/GDBpConnection.h | 6 ++++++ Source/GDBpConnection.m | 39 +++++++++++++++++++++++--------------- 3 files changed, 52 insertions(+), 23 deletions(-) diff --git a/English.lproj/Debugger.xib b/English.lproj/Debugger.xib index 4df873c..e9e66b9 100644 --- a/English.lproj/Debugger.xib +++ b/English.lproj/Debugger.xib @@ -8,7 +8,7 @@ 352.00 YES - + YES @@ -1216,7 +1216,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ arrangedObjects.index NSConditionallySetsEditable - + 2 @@ -1236,7 +1236,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ arrangedObjects.lineNumber NSConditionallySetsEditable - + 2 @@ -1256,7 +1256,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ arrangedObjects.function NSConditionallySetsEditable - + 2 @@ -1271,6 +1271,22 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ 563 + + + value: connection.status + + + + + + value: connection.status + value + connection.status + 2 + + + 564 + @@ -1713,7 +1729,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1808,7 +1824,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ - 563 + 564 @@ -1874,7 +1890,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ runButton sourceViewer stackArrayController - stackController2 statusmsg stepInButton stepOutButton @@ -1889,7 +1904,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ NSToolbarItem BSSourceView NSArrayController - NSArrayController NSTextField NSToolbarItem NSToolbarItem diff --git a/Source/GDBpConnection.h b/Source/GDBpConnection.h index e2ab984..d939c41 100644 --- a/Source/GDBpConnection.h +++ b/Source/GDBpConnection.h @@ -28,11 +28,17 @@ extern NSString *kErrorOccurredNotif; NSString *session; BOOL connected; + /** + * Human-readable status of the connection + */ + NSString *status; + DebuggerController *windowController; SocketWrapper *socket; } +@property(readonly, copy) NSString *status; @property(readonly) SocketWrapper *socket; @property(readonly) DebuggerController *windowController; diff --git a/Source/GDBpConnection.m b/Source/GDBpConnection.m index 31faa62..da3ff9c 100644 --- a/Source/GDBpConnection.m +++ b/Source/GDBpConnection.m @@ -19,15 +19,18 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification"; -@interface GDBpConnection (Private) +@interface GDBpConnection() +@property(readwrite, copy) NSString *status; + - (NSString *)createCommand:(NSString *)cmd; - (NSXMLDocument *)processData:(NSString *)data; - (StackFrame *)createStackFrame; +- (void)updateStatus; @end @implementation GDBpConnection -@synthesize socket, windowController; +@synthesize socket, windowController, status; /** * Creates a new DebuggerConnection and initializes the socket from the given connection @@ -160,22 +163,11 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification"; */ - (void)refreshStatus { - [socket send:[self createCommand:@"status"]]; - - NSXMLDocument *doc = [self processData:[socket receive]]; - NSString *status = [[[doc rootElement] attributeForName:@"status"] stringValue]; - [windowController setStatus:[status capitalizedString]]; - - if ([status isEqualToString:@"break"]) + [self updateStatus]; + if ([status isEqualToString:@"Break"]) { [self updateStackTraceAndRegisters]; } - else if ([status isEqualToString:@"stopped"] || [status isEqualToString:@"stopping"]) - { - connected = NO; - [socket close]; - [windowController setStatus:@"Stopped"]; - } } /** @@ -345,4 +337,21 @@ NSString *kErrorOccurredNotif = @"GDBpConnection_ErrorOccured_Notification"; return [frame autorelease]; } +/** + * Fetches the value of and sets the status instance variable + */ +- (void)updateStatus +{ + [socket send:[self createCommand:@"status"]]; + NSXMLDocument *doc = [self processData:[socket receive]]; + self.status = [[[[doc rootElement] attributeForName:@"status"] stringValue] capitalizedString]; + + if ([status isEqualToString:@"Stopped"] || [status isEqualToString:@"Stopping"]) + { + connected = NO; + [socket close]; + self.status = @"Stopped"; + } +} + @end -- 2.43.5