[Mono-bugs] [Bug 490937] New: TabControl.TabPages.Clear() raise exception when TabControl.SelectedTab != null

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Mar 31 20:20:15 EDT 2009


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


           Summary: TabControl.TabPages.Clear() raise exception when
                    TabControl.SelectedTab != null
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: i586
        OS/Version: openSUSE 11.1
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ctype at mail.ru
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux i686; uk; rv:1.9.0.7)
Gecko/2009022800 SUSE/3.0.7-1.1.6 Firefox/3.0.7 (.NET CLR 3.5.30729)

When TabControl has at least two pages and SelectedTab set to second one
TabControl.TabPages.Clear() throw exception

Reproducible: Always

Steps to Reproduce:
using System;
using System.Windows.Forms;

namespace TabPagesClear
{
    public class TestForm : System.Windows.Forms.Form
    {

        [STAThread]
        static void Main() 
        {
            System.Windows.Forms.Application.Run(new TestForm());    
            Console.WriteLine("Passed");
        }

        public TestForm()
        {
            this.Shown += new System.EventHandler(this.OnShown);
        }

        void OnShown(object sender, System.EventArgs e)
        {
            TabControl tab = new TabControl();
            Controls.Add(tab);
            TabPage tabPage1 = new TabPage();
            TabPage tabPage2 = new TabPage();

            tab.TabPages.Add(tabPage1);
            tab.TabPages.Add(tabPage2);
            tab.SelectedTab = tabPage2;

            //tab.SelectedTab = null; //<<enabling this will fix exception
            tab.TabPages.Clear();
            Close();
        }
    }
}

Actual Results:  
Unhandled Exception: System.ArgumentOutOfRangeException: ControlCollection does
not have that many controls
Parameter name: index
1
  at System.Windows.Forms.Control+ControlCollection.get_Item (Int32 index)
[0x00040] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:492 
  at System.Windows.Forms.TabControl.GetTab (Int32 index) [0x00000] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs:1391 
  at (wrapper remoting-invoke-with-check)
System.Windows.Forms.TabControl:GetTab (int)
  at System.Windows.Forms.TabControl+TabPageCollection.get_Item (Int32 index)
[0x00000] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs:1662 
  at System.Windows.Forms.TabControl.get_SelectedTab () [0x0000e] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs:388 
  at System.Windows.Forms.TabControl.set_SelectedIndex (Int32 value) [0x00095]
in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs:292 
  at (wrapper remoting-invoke-with-check)
System.Windows.Forms.TabControl:set_SelectedIndex (int)
  at System.Windows.Forms.TabControl+ControlCollection.Remove
(System.Windows.Forms.Control value) [0x00076] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs:1629 
  at System.Windows.Forms.Control+ControlCollection.Clear () [0x0000c] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:634 
  at System.Windows.Forms.TabControl+TabPageCollection.Clear () [0x00000] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TabControl.cs:1765 
  at TabPagesClear.TestForm.OnShown (System.Object sender, System.EventArgs e)
[0x0003d] in /home/ctype/dev/app/monobugs/source/TabPages.Clear/MainTest.cs:34 
  at System.Windows.Forms.Form.OnShown (System.EventArgs e) [0x0001c] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs:3299 
  at System.Windows.Forms.Form.SetVisibleCore (Boolean value) [0x00161] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs:2482 
  at System.Windows.Forms.Control.set_Visible (Boolean value) [0x0000c] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:3433 
  at (wrapper remoting-invoke-with-check)
System.Windows.Forms.Control:set_Visible (bool)
  at System.Windows.Forms.Application.RunLoop (Boolean Modal,
System.Windows.Forms.ApplicationContext context) [0x00059] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:862 
  at System.Windows.Forms.Application.Run
(System.Windows.Forms.ApplicationContext context) [0x00014] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:761 
  at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm)
[0x00000] in
/usr/src/packages/BUILD/mono-2.4/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:740 
  at TabPagesClear.TestForm.Main () [0x00000] in
/home/ctype/dev/app/monobugs/source/TabPages.Clear/MainTest.cs:13 

Expected Results:  
Console.WriteLine("Passed");

-- 
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