Author: toshok
Date: 2006-09-26 14:24:48 -0400 (Tue, 26 Sep 2006)
New Revision: 65929
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
Log:
2006-09-26 Chris Toshok <[EMAIL PROTECTED]>
* Control.cs: rework child recreation a little bit. It turns out
that we race between the DestroyNotify the WM_DESTROY message. If
the parent gets its DestroyNotify before the child gets the
WM_DESTROY message, the child ends up not recreating (since the
parent finishes its recreation on DestroyNotify, and the child
checks ParentIsRecreating.)
So, instead we store off a list of all the child controls which
need to be recreated when the parent control starts to recreate
itself. Then, when child controls get their WM_DESTROY message we
check to see if they're in the parent's pending recreation list,
and if so, we recreate. This removes all dependency on ordering
from the code and fixes the initial MonoCalendar upgrade dialog.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-09-26 18:06:30 UTC (rev 65928)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-09-26 18:24:48 UTC (rev 65929)
@@ -1,3 +1,19 @@
+2006-09-26 Chris Toshok <[EMAIL PROTECTED]>
+
+ * Control.cs: rework child recreation a little bit. It turns out
+ that we race between the DestroyNotify the WM_DESTROY message. If
+ the parent gets its DestroyNotify before the child gets the
+ WM_DESTROY message, the child ends up not recreating (since the
+ parent finishes its recreation on DestroyNotify, and the child
+ checks ParentIsRecreating.)
+
+ So, instead we store off a list of all the child controls which
+ need to be recreated when the parent control starts to recreate
+ itself. Then, when child controls get their WM_DESTROY message we
+ check to see if they're in the parent's pending recreation list,
+ and if so, we recreate. This removes all dependency on ordering
+ from the code and fixes the initial MonoCalendar upgrade dialog.
+
2006-09-26 Jackson Harper <[EMAIL PROTECTED]>
* TextControl.cs: Use the Line to get the length of the line,
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-09-26 18:06:30 UTC (rev 65928)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-09-26 18:24:48 UTC (rev 65929)
@@ -73,6 +73,7 @@
internal bool is_captured; //
tracks if the control has captured the mouse
internal bool is_toplevel; //
tracks if the control is a toplevel window
internal bool is_recreating; //
tracks if the handle for the control is being recreated
+ internal ArrayList children_to_recreate; // keep
track of the children which need to be recreated
internal bool causes_validation; //
tracks if validation is executed on changes
internal int tab_index; //
position in tab order of siblings
internal bool tab_stop = true; // is
the control a tab stop?
@@ -885,21 +886,26 @@
return true;
}
- if (parent != null) {
- return parent.IsRecreating;
- }
-
- return false;
+ return ParentWaitingOnRecreation(this);
}
}
- private bool ParentIsRecreating {
- get {
- if (parent != null) {
- return parent.IsRecreating;
- }
- return false;
+ internal bool ChildNeedsRecreating (Control child)
+ {
+ return children_to_recreate != null &&
children_to_recreate.Contains (child);
+ }
+
+ internal void RemoveChildFromRecreateList (Control child)
+ {
+ if (children_to_recreate != null)
+ children_to_recreate.Remove (child);
+ }
+
+ private bool ParentWaitingOnRecreation (Control c) {
+ if (parent != null) {
+ return parent.ChildNeedsRecreating (c);
}
+ return false;
}
internal Graphics DeviceContext {
@@ -2137,7 +2143,9 @@
public bool IsHandleCreated {
get {
if ((window != null) && (window.Handle !=
IntPtr.Zero)) {
- return true;
+ Hwnd hwnd = Hwnd.ObjectFromHandle
(window.Handle);
+ if (hwnd != null && !hwnd.zombie)
+ return true;
}
return false;
@@ -3574,6 +3582,8 @@
is_recreating=true;
if (IsHandleCreated) {
+ children_to_recreate = new ArrayList();
+ children_to_recreate.AddRange
(child_controls.GetAllControls ());
DestroyHandle();
// WM_DESTROY will CreateHandle for us
} else {
@@ -3582,6 +3592,8 @@
} else {
CreateHandle();
}
+ if (parent != null)
+ parent.RemoveChildFromRecreateList
(this);
}
is_recreating = false;
@@ -3924,7 +3936,7 @@
OnHandleDestroyed(EventArgs.Empty);
window.InvalidateHandle();
- if (ParentIsRecreating) {
+ if (ParentWaitingOnRecreation (this)) {
RecreateHandle();
} else if (is_recreating) {
CreateHandle();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches