Fix unreliable variable expansion after debugger steps.
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 12 Apr 2020 16:54:05 +0000 (12:54 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 12 Apr 2020 16:54:05 +0000 (12:54 -0400)
CHANGES
Source/DebuggerController.m

diff --git a/CHANGES b/CHANGES
index deb1db62f7ee0d57f45470ebd171c04da9deba27..f1450eb691de35b4aeae91bf3981eff6407248db 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,7 @@ MacGDBp                                                               CHANGE LOG
 2.0.2
 #####################
 - Fix: Crash when selecting stack frames after disconnecting.
+- Fix: Expanded variables would not reliably re-open after debugger steps.
 
 2.0.1
 #####################
index a34a6b60a17191606896f2e52625d7fdbfaf5734..6e1405792c36ecbc38f01536b33b5cef04b4c897 100644 (file)
                          forKeyPath:@"selection.source"
                             options:NSKeyValueObservingOptionNew
                             context:nil];
+  [_variablesTreeController addObserver:self
+                             forKeyPath:@"arrangedObjects"
+                                options:NSKeyValueObservingOptionNew
+                                context:nil];
   self.connection.autoAttach = [_attachedCheckbox state] == NSOnState;
 
   // Load view controllers into the tab views.
       [_connection loadStackFrame:frame];
   } else if (object == _stackArrayController && [keyPath isEqualToString:@"selection.source"]) {
     [self updateSourceViewer];
+  } else if (object == _variablesTreeController) {
+    [self expandVariables];
   } else if (object == _model) {
     if ([keyPath isEqualToString:@"connected"]) {
       if ([change[NSKeyValueChangeNewKey] boolValue]) {
     [self stepIn:self];
   // Do not cache the file between debugger executions.
   _sourceViewer.file = nil;
+  [_expandedVariables removeAllObjects];
 }
 
 /**
   [_connection stop];
 }
 
-/**
- * NSTableView delegate method that informs the controller that the stack selection did change and that
- * we should update the source viewer
- */
-- (void)tableViewSelectionDidChange:(NSNotification*)notif
-{
-  // 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];
-}
-
 /**
  * Called whenver an item is expanded. This allows us to determine if we need to fetch deeper
  */