[Mono-bugs] [Bug 408999] New: Treeveiw TreeNode.Clear() function fails if there are 50+ nodes

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jul 14 13:19:17 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=408999


           Summary: Treeveiw TreeNode.Clear() function fails if there are
                    50+ nodes
           Product: Mono: Class Libraries
           Version: SVN
          Platform: i386
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jnallen at oakland.edu
         QAContact: mono-bugs at lists.ximian.com
          Found By: Other


Created an attachment (id=227659)
 --> (https://bugzilla.novell.com/attachment.cgi?id=227659)
C# project showing error when calling .Clear() method of treenode with 50+
child nodes

Description of Problem:

A TreeNode has 5000 child nodes.  Call the .Clear() function of the TreeNode to
remove these nodes.  An argument exception is generated.

Unhandled Exception: System.ArgumentException: length
  at System.Array.Copy (System.Array sourceArray, Int32 sourceIndex,
System.Array destinationArray, Int32 destinationIndex, Int32 length) [0x00219]
in /home/calibre/src/mcs/class/corlib/System/Array.cs:987 
  at System.Windows.Forms.TreeNodeCollection.RemoveAt (Int32 index, Boolean
update) [0x00096] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs:375 
  at System.Windows.Forms.TreeNodeCollection.Clear () [0x00005] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs:206 
  at TestCase.Form1.button1_Click (System.Object sender, System.EventArgs e)
[0x00000] 



Steps to reproduce the problem:
1. Create a new winform project.  The form should contain the following two
items:



        private System.Windows.Forms.TreeView treeView1;

        private System.Windows.Forms.Button button1;


2. 

Add 5000 items to a child node in the treeview.  In the button1 event, attempt
to clear these nodes.


       TreeNode Root;           
           TreeNode Child;
           TreeNode SubChild;

        private void button1_Click(object sender, EventArgs e)
        {
            Root = new TreeNode("Root");
            treeView1.Nodes.Add(Root);
            Child = new TreeNode("Child 1");
            Root.Nodes.Add(Child);
                        for (int ix = 0; ix < 50; ix++)
                        {
                                SubChild = new TreeNode("Subchild");
                                Child.Nodes.Add(SubChild);
                        }

                        Child.Nodes.Clear();

        }



3.  Alternatively, you can run the attached source code.  Testcase C# project.



Actual Results:


Unhandled Exception: System.ArgumentException: length
  at System.Array.Copy (System.Array sourceArray, Int32 sourceIndex,
System.Array destinationArray, Int32 destinationIndex, Int32 length) [0x00219]
in /home/calibre/src/mcs/class/corlib/System/Array.cs:987 
  at System.Windows.Forms.TreeNodeCollection.RemoveAt (Int32 index, Boolean
update) [0x00096] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs:375 
  at System.Windows.Forms.TreeNodeCollection.Clear () [0x00005] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs:206 
  at TestCase.Form1.button1_Click (System.Object sender, System.EventArgs e)
[0x00000] 
  at System.Windows.Forms.Control.OnClick (System.EventArgs e) [0x0001c] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5999 
  at System.Windows.Forms.Button.OnClick (System.EventArgs e) [0x00024] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:106 
  at System.Windows.Forms.ButtonBase.OnMouseUp
(System.Windows.Forms.MouseEventArgs mevent) [0x00081] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs:627 
  at System.Windows.Forms.Button.OnMouseUp (System.Windows.Forms.MouseEventArgs
mevent) [0x00000] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:128 
  at System.Windows.Forms.Control.WmLButtonUp (System.Windows.Forms.Message& m)
[0x00081] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5561 
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m)
[0x0017c] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5303 
  at System.Windows.Forms.ButtonBase.WndProc (System.Windows.Forms.Message& m)
[0x00055] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs:685 
  at System.Windows.Forms.Button.WndProc (System.Windows.Forms.Message& m)
[0x00000] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:150 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage
(System.Windows.Forms.Message& m) [0x00000] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:227 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc
(System.Windows.Forms.Message& m) [0x00000] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:208 
  at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr
wParam, IntPtr lParam) [0x00084] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:240 
  at System.Windows.Forms.XplatUIX11.DispatchMessage (System.Windows.Forms.MSG&
msg) [0x00000] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:3296 
  at System.Windows.Forms.XplatUI.DispatchMessage (System.Windows.Forms.MSG&
msg) [0x00000] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs:600 
  at System.Windows.Forms.Application.RunLoop (Boolean Modal,
System.Windows.Forms.ApplicationContext context) [0x00359] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:954 
  at System.Windows.Forms.Application.Run
(System.Windows.Forms.ApplicationContext context) [0x0002e] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:740 
  at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm)
[0x00000] in
/home/calibre/src/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:723 
  at TestCase.Program.Main () [0x00000] 


Expected Results:

The 50 items should be cleared from the treeview.


How often does this happen? 

Everytime.


Additional Information:

The bug does not occur if the treenode has 49 or fewer child nodes.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list