From 3b864743c93c14ebc9f4be00a7dc92695be58c24 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 31 Oct 2010 10:48:36 -0400 Subject: [PATCH] Initial work to get properties loading asynchronously. This may have a memory corruption bug at the moment... --- Source/DebuggerController.h | 6 ++++++ Source/DebuggerController.m | 21 ++++++++++++++++++++- Source/NSXMLElementAdditions.m | 6 +++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Source/DebuggerController.h b/Source/DebuggerController.h index bed4048..d356ad9 100644 --- a/Source/DebuggerController.h +++ b/Source/DebuggerController.h @@ -26,6 +26,10 @@ // This is true when the |connection| has told us to clobber. We will do // so upon receipt of the first new stack frame. BOOL aboutToClobber_; + + // Dictionary of transcations to tree nodes that are used when properties + // are requested from the backend. + NSMutableDictionary* pendingProperties_; StackController* stackController; IBOutlet NSArrayController* stackArrayController; @@ -61,4 +65,6 @@ - (IBAction)stepOver:(id)sender; - (IBAction)reconnect:(id)sender; +- (void)fetchProperty:(NSString*)property forNode:(NSXMLElement*)node; + @end diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index 2f638c3..dee52f7 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -38,7 +38,8 @@ if (self = [super initWithWindowNibName:@"Debugger"]) { stackController = [[StackController alloc] init]; - + pendingProperties_ = [[NSMutableDictionary alloc] init]; + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; connection = [[DebuggerProcessor alloc] initWithPort:[defaults integerForKey:@"Port"]]; @@ -61,6 +62,7 @@ [connection release]; [expandedVariables release]; [stackController release]; + [pendingProperties_ release]; [super dealloc]; } @@ -212,6 +214,12 @@ [connection stepOver]; } +- (void)fetchProperty:(NSString*)property forNode:(NSXMLElement*)node +{ + NSInteger txn = [connection getProperty:property]; + [pendingProperties_ setObject:node forKey:[NSNumber numberWithInt:txn]]; +} + /** * NSTableView delegate method that informs the controller that the stack selection did change and that * we should update the source viewer @@ -339,6 +347,7 @@ - (void)clobberStack { aboutToClobber_ = YES; + [pendingProperties_ removeAllObjects]; } - (void)newStackFrame:(StackFrame*)frame @@ -358,4 +367,14 @@ [self updateSourceViewer]; } +- (void)receivedProperties:(NSArray*)properties forTransaction:(NSInteger)transaction +{ + NSNumber* key = [NSNumber numberWithInt:transaction]; + NSXMLElement* node = [pendingProperties_ objectForKey:key]; + if (node) { + [node setChildren:properties]; + [variablesTreeController rearrangeObjects]; + } +} + @end diff --git a/Source/NSXMLElementAdditions.m b/Source/NSXMLElementAdditions.m index b3ea0b2..d86d03c 100644 --- a/Source/NSXMLElementAdditions.m +++ b/Source/NSXMLElementAdditions.m @@ -50,10 +50,10 @@ - (NSArray*)subnodes { NSArray* children = [self children]; - // If this node has children but they haven't been loaded from the backend, - // request them asynchronously. if (![self isLeaf] && [children count] < 1) { - [[AppDelegate instance].debugger.connection getProperty:[self fullname]]; + // If this node has children but they haven't been loaded from the backend, + // request them asynchronously. + [[AppDelegate instance].debugger fetchProperty:[self fullname] forNode:self]; } return children; } -- 2.43.5