From 104c37c820c3166637638b1a91063f693857e9e8 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 26 Feb 2011 12:14:51 -0500 Subject: [PATCH] Close and reopen the connection when toggling the attached state. --- Source/DebuggerBackEnd.h | 2 +- Source/DebuggerBackEnd.m | 17 ++++++++++++++++- Source/NetworkConnection.mm | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/DebuggerBackEnd.h b/Source/DebuggerBackEnd.h index 255b585..8de4c2e 100644 --- a/Source/DebuggerBackEnd.h +++ b/Source/DebuggerBackEnd.h @@ -65,7 +65,7 @@ } @property (readonly, copy) NSString* status; -@property (assign) BOOL attached; +@property (nonatomic, assign) BOOL attached; @property (assign) id delegate; // initializer diff --git a/Source/DebuggerBackEnd.m b/Source/DebuggerBackEnd.m index 92cd9d5..215750d 100644 --- a/Source/DebuggerBackEnd.m +++ b/Source/DebuggerBackEnd.m @@ -60,7 +60,8 @@ [[BreakpointManager sharedManager] setConnection:self]; connection_ = [[NetworkConnection alloc] initWithPort:aPort]; connection_.delegate = self; - [connection_ connect]; + if (self.attached) + [connection_ connect]; attached_ = [[NSUserDefaults standardUserDefaults] boolForKey:@"DebuggerAttached"]; } @@ -99,6 +100,20 @@ return [connection_ connected] && active_; } +/** + * Sets the attached state of the debugger. This will open and close the + * connection as appropriate. + */ +- (void)setAttached:(BOOL)attached { + if (attached != attached_) { + if (!attached) + [connection_ close]; + else + [connection_ connect]; + } + attached_ = attached; +} + // Commands //////////////////////////////////////////////////////////////////// #pragma mark Commands diff --git a/Source/NetworkConnection.mm b/Source/NetworkConnection.mm index 894b1d7..89b9a67 100644 --- a/Source/NetworkConnection.mm +++ b/Source/NetworkConnection.mm @@ -103,6 +103,7 @@ void PerformQuitSignal(void* info) CFRunLoopSourceInvalidate(quitSource_); CFRelease(quitSource_); quitSource_ = NULL; + NSLog(@"stopping network thread"); [pool release]; } -- 2.43.5