[Mono-dev] Fix for failing TreeNodeTest.FullPathTest
Dieter Bremes
dbjobs at snafu.de
Mon Dec 12 15:54:14 EST 2005
Hi,
below is a fix to TreeNodeCollection.cs to prevent
TreeNodeTest.FullPathTest from failing and some other problems.
OTOH I wonder how such obvious bugs could make it into the trunk
especially as there a test that clearly catches at least one of them.
Dieter
* TreeNodeCollection.cs : Fixed bugs that among
<http://dict.leo.org/se?lp=ende&p=/Mn4k.&search=among> other
<http://dict.leo.org/se?lp=ende&p=/Mn4k.&search=other> things
<http://dict.leo.org/se?lp=ende&p=/Mn4k.&search=things> caused
TreeNodeTest.FullPathTest to fail.
Index: TreeNodeCollection.cs
===================================================================
--- TreeNodeCollection.cs (Revision 54253)
+++ TreeNodeCollection.cs (Arbeitskopie)
@@ -115,18 +115,20 @@
// Remove it from any old parents
node.Remove ();
- TreeView tree_view = owner.TreeView;
- if (owner != null && tree_view != null &&
tree_view.Sorted)
+ TreeView tree_view = null;
+ if (owner != null)
+ tree_view = owner.TreeView;
+ if (tree_view != null && tree_view.Sorted)
return AddSorted (node);
node.parent = owner;
if (count >= nodes.Length)
Grow ();
nodes [count++] = node;
- if (tree_view != null && (owner.IsExpanded ||
owner.IsRoot)) {
+ if (owner != null && tree_view != null &&
(owner.IsExpanded || owner.IsRoot)) {
// XXX: Need to ensure the boxes for the
nodes have been created
tree_view.UpdateNode (owner);
- } else if (tree_view != null) {
+ } else if (owner != null && tree_view != null) {
tree_view.UpdateNodePlusMinus (owner);
}
@@ -152,9 +154,12 @@
Array.Clear (nodes, 0, count);
count = 0;
- TreeView tree_view = owner.TreeView;
- if (tree_view != null)
- tree_view.UpdateBelow (owner);
+ TreeView tree_view = null;
+ if (owner != null) {
+ tree_view = owner.TreeView;
+ if (tree_view != null)
+ tree_view.UpdateBelow (owner);
+ }
}
public bool Contains (TreeNode node)
@@ -210,8 +215,10 @@
if (nodes.Length > OrigSize && nodes.Length >
(count * 2))
Shrink ();
- TreeView tree_view = owner.TreeView;
- if (removed == tree_view.top_node) {
+ TreeView tree_view = null;
+ if (owner != null)
+ tree_view = owner.TreeView;
+ if (tree_view != null && removed ==
tree_view.top_node) {
OpenTreeNodeEnumerator oe = new
OpenTreeNodeEnumerator (removed);
if (oe.MoveNext () && oe.MoveNext ())
tree_view.top_node = oe.CurrentNode;
More information about the Mono-devel-list
mailing list