Author: ivanz
Date: 2008-02-18 11:38:00 -0500 (Mon, 18 Feb 2008)
New Revision: 96072
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
Log:
2008-02-18 Ivan N. Zlatev <[EMAIL PROTECTED]>
* Control.cs: During diposing firstly remove ourselfes from
the parent and *then* destroy our handle, because removing
ourselfes from the parent controls collection causes
VisibilityChange, etc events, which require a handle and end
up recreating the control.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2008-02-18 16:37:45 UTC (rev 96071)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2008-02-18 16:38:00 UTC (rev 96072)
@@ -1,3 +1,11 @@
+2008-02-18 Ivan N. Zlatev <[EMAIL PROTECTED]>
+
+ * Control.cs: During diposing firstly remove ourselfes from
+ the parent and *then* destroy our handle, because removing
+ ourselfes from the parent controls collection causes
+ VisibilityChange, etc events, which require a handle and end
+ up recreating the control.
+
2008-02-17 Ivan N. Zlatev <[EMAIL PROTECTED]>
* GridEntry.cs: Set expanded state before notifying that the
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-18 16:37:45 UTC (rev 96071)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2008-02-18 16:38:00 UTC (rev 96072)
@@ -1122,6 +1122,13 @@
if (!is_disposed && disposing) {
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) {
@@ -1132,10 +1139,6 @@
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
@@ -1850,18 +1853,6 @@
parent = new_parent;
- // reset properties back to their pre-parent-change
values if there is
- // no new parent (i.e., the control is changing parents
because it's
- // being removed. See #355850)
- if (parent == null) {
- is_enabled = pre_enabled;
- is_visible = pre_visible;
- font = pre_font;
- foreground_color = pre_fore_color;
- background_color = pre_back_color;
- right_to_left = pre_rtl;
- }
-
Form frm = this as Form;
if (frm != null) {
frm.ChangingParent (new_parent);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches