Author: toshok
Date: 2006-08-28 12:37:44 -0400 (Mon, 28 Aug 2006)
New Revision: 64480
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: err, fix this the right way, by locking on controls
when using it. not by making it synchronized.
2006-08-28 Chris Toshok <[EMAIL PROTECTED]>
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-08-28 16:29:33 UTC (rev 64479)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-08-28 16:37:44 UTC (rev 64480)
@@ -1,5 +1,10 @@
2006-08-28 Chris Toshok <[EMAIL PROTECTED]>
+ * Control.cs: err, fix this the right way, by locking on controls
+ when using it. not by making it synchronized.
+
+2006-08-28 Chris Toshok <[EMAIL PROTECTED]>
+
* Control.cs: make the static "controls" field synchronized, as it
gets updated from multiple threads.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-08-28 16:29:33 UTC (rev 64479)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-08-28 16:37:44 UTC (rev 64480)
@@ -105,7 +105,7 @@
internal int dist_bottom; //
distance to the bottom border of the parent
// to be categorized...
- static internal ArrayList controls =
ArrayList.Synchronized (new ArrayList()); // All of the application's
controls, in a flat list
+ static internal ArrayList controls = new ArrayList(); //
All of the application's controls, in a flat list
internal ControlCollection child_controls; // our
children
internal Control parent; // our
parent control
internal AccessibleObject accessibility_object; //
object that contains accessibility information about our control
@@ -773,7 +773,9 @@
}
} else {
DestroyHandle();
- controls.Remove(this);
+ lock (Control.controls) {
+ Control.controls.Remove(this);
+ }
}
@@ -2605,17 +2607,19 @@
#region Public Static Methods
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static Control FromChildHandle(IntPtr handle) {
- IEnumerator control = Control.controls.GetEnumerator();
+ lock (Control.controls) {
+ IEnumerator control =
Control.controls.GetEnumerator();
- while (control.MoveNext()) {
- if (((Control)control.Current).window.Handle ==
handle) {
- // Found it
- if (((Control)control.Current).Parent
!= null) {
- return
((Control)control.Current).Parent;
+ while (control.MoveNext()) {
+ if
(((Control)control.Current).window.Handle == handle) {
+ // Found it
+ if
(((Control)control.Current).Parent != null) {
+ return
((Control)control.Current).Parent;
+ }
}
}
+ return null;
}
- return null;
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
@@ -3304,8 +3308,10 @@
window.CreateHandle(CreateParams);
if (window.Handle != IntPtr.Zero) {
- if (!controls.Contains(window.Handle)) {
- controls.Add(this);
+ lock (Control.controls) {
+ if
(!Control.controls.Contains(window.Handle)) {
+ Control.controls.Add(this);
+ }
}
creator_thread = Thread.CurrentThread;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches