From f972ef39c5946d67865bea8def876254bc286ff0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 16 Dec 2010 09:06:59 -0500 Subject: [PATCH] Do away with the concept of "reconnect" and use a checbox for attached/detached state. * |-[DebuggerConnectionDelegate connectionDidAccept:]| now actually gets signaled * When the debugger is in "detached" mode, it will automatically reject new client sockets. --- English.lproj/Debugger.xib | 230 +++++++++++++++++++++++++----------- Source/DebuggerConnection.h | 8 -- Source/DebuggerConnection.m | 17 +-- Source/DebuggerController.h | 3 +- Source/DebuggerController.m | 10 +- Source/DebuggerProcessor.h | 6 +- Source/DebuggerProcessor.m | 18 ++- 7 files changed, 181 insertions(+), 111 deletions(-) diff --git a/English.lproj/Debugger.xib b/English.lproj/Debugger.xib index 10cf097..6ef7069 100644 --- a/English.lproj/Debugger.xib +++ b/English.lproj/Debugger.xib @@ -2,9 +2,9 @@ 1050 - 10F569 + 10H574 804 - 1038.29 + 1038.35 461.00 com.apple.InterfaceBuilder.CocoaPlugin @@ -12,8 +12,7 @@ YES - - + YES @@ -56,11 +55,11 @@ YES YES + 0DD9463E-4676-43E6-B885-7A9CB1137956 4F493FF4-D55D-4881-B16D-54ED9DC66FF7 87BEA2D0-EF8E-4DF2-9827-B2AC06858DC6 91C3B0BD-0D34-4A26-A0EA-CC2A093F5916 9FD4795A-41D6-49D4-94CE-99E9DF733A09 - DD23489D-A21C-474A-84A1-392673464E24 E0B2A793-522F-487A-AF2E-BE7FDFF26543 NSToolbarCustomizeToolbarItem NSToolbarFlexibleSpaceItem @@ -69,6 +68,91 @@ YES + + + 0DD9463E-4676-43E6-B885-7A9CB1137956 + + Attached + + + + + 268 + {{0, 14}, {83, 18}} + + YES + + -2080244224 + 0 + Attached + + LucidaGrande + 13 + 1044 + + + 1211912703 + 2 + + NSImage + NSSwitch + + + NSSwitch + + + + 200 + 25 + + + + 12779520 + + YES + + YES + + + + YES + + YES + size + state + value + widget + + + YES + regular + normal + + checkbox + + + {18, 18} + 0 + YES + NSCalibratedRGBColorSpace + + + + + 3 + MCAwAA + + + + + {63, 18} + {107, 18} + YES + YES + 0 + YES + 0 + 4F493FF4-D55D-4881-B16D-54ED9DC66FF7 @@ -157,28 +241,6 @@ YES 0 - - - DD23489D-A21C-474A-84A1-392673464E24 - - Reconnect - Reconnect - - - - NSImage - Reconnect.png - - - - {0, 0} - {0, 0} - YES - YES - -1 - YES - 0 - E0B2A793-522F-487A-AF2E-BE7FDFF26543 @@ -316,12 +378,12 @@ - + YES @@ -334,7 +396,7 @@ - + YES @@ -919,7 +981,7 @@ {1.79769e+308, 1.79769e+308} - + 256 YES @@ -1135,7 +1197,6 @@ {402, 402} - @@ -1168,7 +1229,6 @@ {{-1, -1}, {402, 402}} - 560 @@ -1176,7 +1236,6 @@ {400, 400} - {{0, 0}, {1440, 878}} {1.79769e+308, 1.79769e+308} @@ -1301,14 +1360,6 @@ 487 - - - reconnect: - - - - 488 - sourceViewer @@ -1553,6 +1604,14 @@ 590 + + + attachedToggled: + + + + 594 + @@ -1655,11 +1714,11 @@ - - + + @@ -1688,16 +1747,6 @@ - - 480 - - - - - 481 - - - 482 @@ -1963,6 +2012,34 @@ + + 593 + + + YES + + + + + + 591 + + + YES + + + + + + 592 + + + + + 480 + + + @@ -2032,7 +2109,6 @@ 48.IBPluginDependency 48.ImportedFromIB2 480.IBPluginDependency - 481.IBPluginDependency 482.IBPluginDependency 483.IBPluginDependency 495.IBPluginDependency @@ -2052,6 +2128,8 @@ 584.IBPluginDependency 59.IBPluginDependency 59.ImportedFromIB2 + 591.IBPluginDependency + 592.IBPluginDependency 7.IBEditorWindowLastContentRect 7.IBPluginDependency 7.IBViewEditorWindowController.showingBoundsRectangles @@ -2126,7 +2204,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{445, 738}, {617, 0}} + {{449, 334}, {617, 227}} com.apple.InterfaceBuilder.CocoaPlugin {{418, 770}, {617, 0}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2138,7 +2216,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin BSSplitView com.apple.InterfaceBuilder.CocoaPlugin {{478, 327}, {400, 400}} @@ -2154,11 +2231,13 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{369, 237}, {769, 501}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{373, 60}, {769, 501}} com.apple.InterfaceBuilder.CocoaPlugin - {{369, 237}, {769, 501}} + {{373, 60}, {769, 501}} {{344, 269}, {769, 501}} @@ -2188,7 +2267,7 @@ - 590 + 594 @@ -2235,8 +2314,7 @@ YES YES - reconnect: - run: + attachedToggled: showInspectorWindow: stepIn: stepOut: @@ -2249,15 +2327,13 @@ id id id - id YES YES - reconnect: - run: + attachedToggled: showInspectorWindow: stepIn: stepOut: @@ -2266,11 +2342,7 @@ YES - reconnect: - id - - - run: + attachedToggled: id @@ -2452,6 +2524,22 @@ AppKit.framework/Headers/NSArrayController.h + + NSButton + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSButton.h + + + + NSButtonCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSButtonCell.h + + NSCell NSObject @@ -2993,8 +3081,8 @@ HUDIcon.png NSMenuCheckmark NSMenuMixedState + NSSwitch NSToolbarCustomizeToolbarItemImage - Reconnect.png Run.png StepIn.png StepOut.png @@ -3005,12 +3093,12 @@ {128, 128} {9, 8} {7, 2} + {15, 15} {32, 32} {128, 128} {128, 128} {128, 128} {128, 128} - {128, 128} diff --git a/Source/DebuggerConnection.h b/Source/DebuggerConnection.h index 87029a1..01c2bb1 100644 --- a/Source/DebuggerConnection.h +++ b/Source/DebuggerConnection.h @@ -31,9 +31,6 @@ // If the connection to the debugger engine is currently active. BOOL connected_; - // Whether or not in reconnect mode. - BOOL reconnect_; - // The thread on which network operations are performed. Weak. NSThread* thread_; @@ -84,7 +81,6 @@ @property (readonly) NSUInteger port; @property (readonly) BOOL connected; -@property (readonly, getter=inReconnectMode) BOOL reconnect; @property (assign) id delegate; - (id)initWithPort:(NSUInteger)aPort; @@ -92,10 +88,6 @@ - (void)connect; - (void)close; -// Marks the connection as being in "reconnect mode," which sets the expectation -// of receiving another message. -- (void)reconnect; - - (void)send:(NSString*)command; // This sends the given command format to the debugger. This method is thread diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index f7ec997..8c4b055 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -123,8 +123,6 @@ void SocketAcceptCallback(CFSocketRef socket, NSLog(@"SocketAcceptCallback()"); DebuggerConnection* connection = (DebuggerConnection*)connectionRaw; - if (![connection inReconnectMode]) - return; CFReadStreamRef readStream; CFWriteStreamRef writeStream; @@ -202,7 +200,6 @@ void PerformQuitSignal(void* info) @synthesize port = port_; @synthesize connected = connected_; -@synthesize reconnect = reconnect_; @synthesize delegate = delegate_; @synthesize socket = socket_; @@ -218,7 +215,6 @@ void PerformQuitSignal(void* info) if (self = [super init]) { port_ = aPort; - reconnect_ = YES; } return self; } @@ -229,12 +225,6 @@ void PerformQuitSignal(void* info) [super dealloc]; } -- (void)reconnect -{ - connected_ = NO; - reconnect_ = YES; -} - /** * Kicks off the socket on another thread. */ @@ -337,6 +327,10 @@ void PerformQuitSignal(void* info) lastWrittenTransaction_ = 0; self.queuedWrites = [NSMutableArray array]; writeQueueLock_ = [NSRecursiveLock new]; + if ([delegate_ respondsToSelector:@selector(connectionDidAccept:)]) + [delegate_ performSelectorOnMainThread:@selector(connectionDidAccept:) + withObject:self + waitUntilDone:NO]; } /** @@ -630,7 +624,7 @@ void PerformQuitSignal(void* info) // Otherwise, assume +1 and hope it works. ++lastReadTransaction_; - } else if (!reconnect_) { + } else /*if (!reconnect_)*/ { // See if the transaction can be parsed out. NSInteger transaction = [self transactionIDFromResponse:xmlTest]; if (transaction < lastReadTransaction_) { @@ -666,7 +660,6 @@ void PerformQuitSignal(void* info) if ([[[response rootElement] name] isEqualToString:@"init"]) { connected_ = YES; - reconnect_ = NO; [delegate_ performSelectorOnMainThread:@selector(handleInitialResponse:) withObject:response waitUntilDone:NO]; diff --git a/Source/DebuggerController.h b/Source/DebuggerController.h index b1aaab6..cd464b4 100644 --- a/Source/DebuggerController.h +++ b/Source/DebuggerController.h @@ -60,11 +60,12 @@ - (void)startDebugger; +- (IBAction)attachedToggled:(id)sender; + - (IBAction)run:(id)sender; - (IBAction)stepIn:(id)sender; - (IBAction)stepOut:(id)sender; - (IBAction)stepOver:(id)sender; -- (IBAction)reconnect:(id)sender; - (void)fetchChildProperties:(VariableNode*)node; diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index 923ce0f..48779de 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -158,7 +158,7 @@ - (void)debuggerDisconnected { if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AutoReconnect"]) - [self reconnect:self]; + ; // TODO: fix // Invalidate the marked line so we don't look like we're still running. sourceViewer.markedLine = -1; @@ -173,13 +173,9 @@ [connection run]; } -/** - * Tells the connection to ask the server to reconnect - */ -- (IBAction)reconnect:(id)sender +- (IBAction)attachedToggled:(id)sender { - [connection reconnect]; - [self resetDisplays]; + connection.attached = [sender state] == NSOnState; } /** diff --git a/Source/DebuggerProcessor.h b/Source/DebuggerProcessor.h index 7f6299b..b736032 100644 --- a/Source/DebuggerProcessor.h +++ b/Source/DebuggerProcessor.h @@ -38,6 +38,10 @@ // Human-readable status of the connection. NSString* status; BOOL active_; + + // Whether the debugger should detach immediately after being contacted by the + // backend. YES means all debugger connections will be dropped. + BOOL attached_; // The connection's delegate. id delegate; @@ -61,6 +65,7 @@ } @property (readonly, copy) NSString* status; +@property (assign) BOOL attached; @property (assign) id delegate; // initializer @@ -72,7 +77,6 @@ - (BOOL)isConnected; // communication -- (void)reconnect; - (void)run; - (void)stepIn; - (void)stepOut; diff --git a/Source/DebuggerProcessor.m b/Source/DebuggerProcessor.m index 9fc6f7d..0e0e3bb 100644 --- a/Source/DebuggerProcessor.m +++ b/Source/DebuggerProcessor.m @@ -42,6 +42,7 @@ @implementation DebuggerProcessor @synthesize status; +@synthesize attached = attached_; @synthesize delegate; /** @@ -111,17 +112,6 @@ // Commands //////////////////////////////////////////////////////////////////// #pragma mark Commands -/** - * Reestablishes communication with the remote debugger so that a new connection doesn't have to be - * created every time you want to debug a page - */ -- (void)reconnect -{ - self.status = @"Connecting"; - active_ = NO; - [connection_ reconnect]; -} - /** * Tells the debugger to continue running the script. Returns the current stack frame. */ @@ -222,6 +212,12 @@ // Specific Response Handlers ////////////////////////////////////////////////// #pragma mark Response Handlers +- (void)connectionDidAccept:(DebuggerConnection*)cx +{ + if (!self.attached) + [connection_ sendCommandWithFormat:@"detach"]; +} + - (void)errorEncountered:(NSString*)error { [delegate errorEncountered:error]; -- 2.43.5