diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs index 70415d8c5a..4501da9d35 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs @@ -230,9 +230,12 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads using(new PrintTimes("Local Variables refresh")) { try { + localVarList.BeginUpdate(); Utils.DoEvents(debuggedProcess.DebuggeeState); TreeViewNode.SetContentRecursive(this, localVarList.Root.Children, new StackFrameNode(debuggedProcess.SelectedStackFrame).ChildNodes); } catch(AbortedBecauseDebuggeeResumedException) { + } finally { + localVarList.EndUpdate(); } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewNode.cs index 08dba0d9d5..e2857d52c4 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewNode.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewNode.cs @@ -12,6 +12,8 @@ using System.Windows.Forms; using Aga.Controls.Tree; +using Debugger.Util; + using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui.Pads; @@ -51,6 +53,9 @@ namespace Debugger.AddIn.TreeModel SetContentRecursive(content); } + static TimeSpan workTime = TimeSpan.FromMilliseconds(40); + static DateTime nextRepaintTime = DateTime.MinValue; + public void SetContentRecursive(AbstractNode content) { this.textChanged = @@ -68,9 +73,20 @@ namespace Debugger.AddIn.TreeModel this.Children.Clear(); this.Collapse(); } - this.Tree.Invalidate(); - // Repaint and process user commands + // Process user commands Utils.DoEvents(localVarPad.Process.DebuggeeState); + // Repaint + if (HighPrecisionTimer.Now > nextRepaintTime) { + using(new PrintTime("Repainting Local Variables Pad")) { + try { + this.Tree.EndUpdate(); // Enable painting + Utils.DoEvents(localVarPad.Process.DebuggeeState); // Paint + } finally { + this.Tree.BeginUpdate(); // Disable painting + nextRepaintTime = HighPrecisionTimer.Now + workTime; + } + } + } } public static void SetContentRecursive(LocalVarPad localVarPad, IList childNodes, IEnumerable contentEnum) @@ -115,8 +131,11 @@ namespace Debugger.AddIn.TreeModel base.OnExpanded(); expandedNodes[FullName] = true; try { + this.Tree.BeginUpdate(); LoadChilds(); } catch (AbortedBecauseDebuggeeResumedException) { + } finally { + this.Tree.EndUpdate(); } } diff --git a/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs b/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs index e559e9baa9..2cc78ca2db 100644 --- a/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs +++ b/src/Libraries/TreeViewAdv/Aga.Controls/Tree/TreeViewAdv.cs @@ -29,7 +29,7 @@ namespace Aga.Controls.Tree private Pen _linePen; private Pen _markPen; - private bool _suspendUpdate; + private int _suspendUpdate = 0; private bool _needFullUpdate; private bool _fireSelectionEvent; private NodePlusMinus _plusMinus; @@ -318,18 +318,23 @@ namespace Aga.Controls.Tree public void BeginUpdate() { - _suspendUpdate = true; + _suspendUpdate++; SuspendSelectionEvent = true; } public void EndUpdate() { - _suspendUpdate = false; - if (_needFullUpdate) - FullUpdate(); - else - UpdateView(); - SuspendSelectionEvent = false; + if (_suspendUpdate == 0) { + throw new Exception("Number of calls to BeginUpdate does not match number of calls to EndUpdate."); + } + _suspendUpdate--; + if (_suspendUpdate == 0) { + if (_needFullUpdate) + FullUpdate(); + else + UpdateView(); + SuspendSelectionEvent = false; + } } public void ExpandAll() @@ -620,7 +625,7 @@ namespace Aga.Controls.Tree internal void UpdateView() { - if (!_suspendUpdate) + if (_suspendUpdate == 0) Invalidate(false); } @@ -909,7 +914,7 @@ namespace Aga.Controls.Tree internal void SmartFullUpdate() { - if (_suspendUpdate) + if (_suspendUpdate > 0) _needFullUpdate = true; else FullUpdate();