Skip to content

Commit

Permalink
Fix #407: Copy to clipboard hangs on large files
Browse files Browse the repository at this point in the history
  • Loading branch information
clovett committed Sep 21, 2024
1 parent c76b9c6 commit d209332
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/Application/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public FormMain(SettingsLocation location)
this.ContextMenuStrip = this.contextMenu1;
New();

this.xsltViewer.Visible = false;
if (!testing)
{
_ = AsyncSetup();
Expand Down Expand Up @@ -736,11 +737,13 @@ protected virtual void TabControlViews_Selected(object sender, NoBorderTabContro
{
this.helpProvider1.HelpNamespace = this._helpService.XsltHelp;
this.CheckWebViewVersion();
this.xsltViewer.Visible = true;
this.DisplayXsltResults();
}
else
{
this.helpProvider1.HelpNamespace = this._helpService.DefaultHelp;
this.xsltViewer.Visible = false;
this.xsltViewer.OnClosed(); // good time to cleanup temp files.
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/XmlNotepad/NodeTextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ class AccessibleNodeTextViewNode : AccessibleObject
private TreeNode _node;
private NodeTextView _view;
private AccessibleNodeTextView _acc;
private int _childCount = -1;

public AccessibleNodeTextViewNode(AccessibleNodeTextView acc, TreeNode node)
{
Expand Down Expand Up @@ -1159,11 +1160,17 @@ public override string Description
}
public override void DoDefaultAction()
{
_childCount = -1;
_node.Toggle();
}
public override int GetChildCount()
{
return _node.Children.Count;
if (_childCount == -1)
{
// This can be VERY slow as it populates the children right here!
_childCount = _node.Children.Count;
}
return _childCount;
}
public override AccessibleObject GetChild(int index)
{
Expand Down
5 changes: 3 additions & 2 deletions src/XmlNotepad/TreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1685,9 +1685,10 @@ internal void DrawLabel2(Graphics g, Font f)

internal static TreeNodeCollection GetChildren(TreeNode n)
{
if (n.Children.Count > 0)
var children = n.Children;
if (children.Count > 0)
{
return n.Children;
return children;
}
return null;
}
Expand Down
7 changes: 6 additions & 1 deletion src/XmlNotepad/XmlTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,7 @@ public class XmlTreeNode : TreeNode, IXmlTreeNode
private string _editLabel;
private string _schemaAwareText;
private Color _schemaAwareColor;
private TreeNodeCollection _lazyChildren;

public XmlTreeNode(XmlTreeView view)
{
Expand Down Expand Up @@ -2062,7 +2063,11 @@ public override TreeNodeCollection Children
{
get
{
return new XmlTreeNodeCollection(this);
if (this._lazyChildren == null)
{
this._lazyChildren = new XmlTreeNodeCollection(this);
}
return _lazyChildren;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/XmlNotepad/XsltViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void OnModelChanged(ModelChangedEventArgs e)
{
this.SourceFileName.Text = _model.XsltFileName;
}
if (e.ModelChangeType == ModelChangeType.Reloaded)
if (e.ModelChangeType == ModelChangeType.Reloaded && this.Visible)
{
this.delayedActions.StartDelayedAction("UpdateXslt", DisplayXsltResults, TimeSpan.FromSeconds(0.5));
}
Expand Down

0 comments on commit d209332

Please sign in to comment.