[fix] changing Form.Enabled sometimes can change the list of OpenForms, fixes 671098
authorMiguel de Icaza <miguel@gnome.org>
Fri, 11 Feb 2011 22:34:23 +0000 (17:34 -0500)
committerMiguel de Icaza <miguel@gnome.org>
Fri, 11 Feb 2011 22:34:34 +0000 (17:34 -0500)
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs

index ebf99667a65ad78c47f0c4b8a6b549800f0192cb..8db32b5d547d0b54193f8dc39d609afa03ebc677 100644 (file)
@@ -33,6 +33,7 @@ using System.ComponentModel.Design.Serialization;
 using System.Collections;
 using System.Runtime.InteropServices;
 using System.Threading;
+using System.Collections.Generic;
 
 namespace System.Windows.Forms {
        [DesignerCategory("Form")]
@@ -1717,13 +1718,13 @@ namespace System.Windows.Forms {
                                XplatUI.UngrabWindow(capture_window);
                        }
 
+                       var disable = new List<Form> ();
                        foreach (Form form in Application.OpenForms)
-                       {
-                               if (form.Enabled == true)
-                               {
-                                       disabled_by_showdialog.Add(form);
-                                       form.Enabled = false;
-                               }
+                               if (form.Enabled)
+                                       disable.Add (form);
+                       foreach (Form form in disable){
+                               disabled_by_showdialog.Add (form);
+                               form.Enabled = false;
                        }
                        modal_dialogs.Add(this);