Author: andreia Date: 2008-02-19 11:50:50 -0500 (Tue, 19 Feb 2008) New Revision: 96163
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs Log: * Control.cs: Added a new flag is_disposing to track if the window is currently in the process of being disposed of. This is used so that, when firing visibility changes triggered by unparenting controls during Dispose, the control doesn't get created again. 2008-02-19 Andreia Gaita <[EMAIL PROTECTED]> Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog 2008-02-19 16:42:25 UTC (rev 96162) +++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog 2008-02-19 16:50:50 UTC (rev 96163) @@ -1,3 +1,11 @@ +2008-02-19 Andreia Gaita <[EMAIL PROTECTED]> + + * Control.cs: Added a new flag is_disposing to track if the + window is currently in the process of being disposed of. + This is used so that, when firing visibility changes triggered + by unparenting controls during Dispose, the control doesn't + get created again. + 2008-02-19 Jonathan Pobst <[EMAIL PROTECTED]> * ComboBox.cs: Set height to preferred height when the handle Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs 2008-02-19 16:42:25 UTC (rev 96162) +++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs 2008-02-19 16:50:50 UTC (rev 96163) @@ -88,6 +88,7 @@ int tab_index; // position in tab order of siblings bool tab_stop; // is the control a tab stop? bool is_disposed; // has the window already been disposed? + bool is_disposing; // is the window getting disposed? Size client_size; // size of the client area (window excluding decorations) Rectangle client_rect; // rectangle with the client area (window excluding decorations) ControlStyles control_style; // rather win32-specific, style bits for control @@ -1120,15 +1121,9 @@ protected override void Dispose (bool disposing) { if (!is_disposed && disposing) { + is_disposing = true; Capture = false; - // Remove fires events like VisibleChanged, etc, so - // which require a handle or else they will recreate the control, - // so do not move this after DestroyHandle. - // - if (parent != null) - parent.Controls.Remove(this); - DisposeBackBuffer (); if (this.InvokeRequired) { @@ -1139,6 +1134,9 @@ DestroyHandle(); } + if (parent != null) + parent.Controls.Remove(this); + Control [] children = child_controls.GetAllControls (); for (int i=0; i<children.Length; i++) { children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash @@ -1146,6 +1144,7 @@ } } is_disposed = true; + is_disposing = false; is_visible = false; base.Dispose(disposing); } @@ -3710,6 +3709,10 @@ return; } + if (is_disposing) { + return; + } + if (!is_visible) { return; } _______________________________________________ Mono-patches maillist - Mono-patches@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-patches