Add a hack to get |-expandVariables| working.
authorRobert Sesek <rsesek@bluestatic.org>
Fri, 24 Dec 2010 00:41:36 +0000 (19:41 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Fri, 24 Dec 2010 00:41:36 +0000 (19:41 -0500)
Source/DebuggerController.m

index 6dbf56761877b3f375d480904727192aac2937b3..96a5ca7743fa184bef74c5bf84bcee06b4dc555b 100644 (file)
 - (void)fetchChildProperties:(VariableNode*)node
 {
   NSArray* selection = [stackArrayController selectedObjects];
+  if (![selection count])
+    return;
   assert([selection count] == 1);
   NSInteger depth = [[selection objectAtIndex:0] index];
   NSInteger txn = [connection getChildrenOfProperty:node atDepth:depth];
 - (void)tableViewSelectionDidChange:(NSNotification*)notif
 {
   [self updateSourceViewer];
-  [self expandVariables];
+  // TODO: This is very, very hacky because it's nondeterministic. The issue
+  // is that calling |-[NSOutlineView expandItem:]| while the table is still
+  // doing its redraw will translate to a no-op. Instead, we need to restructure
+  // this controller so that when everything has been laid out we call
+  // |-expandVariables|; but NSOutlineView doesn't have a |-didFinishDoingCrap:|
+  // method. The other issue is that we need to call this method from
+  // selectionDidChange but ONLY when it was the result of a user-initiated
+  // action and not the stack viewer updating causing a selection change.
+  // If it happens in the latter, then we run into the same issue that causes
+  // this to no-op.
+  [self performSelector:@selector(expandVariables) withObject:nil afterDelay:0.05];
 }
 
 /**
 {
   [stackArrayController rearrangeObjects];
   [stackArrayController setSelectionIndex:0];
-  [self expandVariables];
 }
 
 /**
 - (void)expandVariables
 {
   NSString* selection = [selectedVariable fullName];
-  
-  for (int i = 0; i < [variablesOutlineView numberOfRows]; i++)
-  {
+
+  for (int i = 0; i < [variablesOutlineView numberOfRows]; i++) {
     NSTreeNode* node = [variablesOutlineView itemAtRow:i];
     NSString* fullName = [[node representedObject] fullName];