Author: toshok
Date: 2006-10-30 18:31:37 -0500 (Mon, 30 Oct 2006)
New Revision: 67161

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ApplicationContext.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
Log:
        * ApplicationContext.cs: guard against a NRE.

        * Application.cs: null out the old MainForm for the context, so we
        don't try to use it again once it's disposed.  Fixes bug #79783.

2006-10-30  Chris Toshok  <[EMAIL PROTECTED]>



Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs   
2006-10-30 23:29:15 UTC (rev 67160)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs   
2006-10-30 23:31:37 UTC (rev 67161)
@@ -478,8 +478,10 @@
                                }
                                // FIXME - need activate?
                                /* make sure the MainForm is enabled */
-                               XplatUI.EnableWindow (context.MainForm.Handle, 
true);
-                               XplatUI.SetModal(context.MainForm.Handle, true);
+                               if (context.MainForm != null) {
+                                       XplatUI.EnableWindow 
(context.MainForm.Handle, true);
+                                       
XplatUI.SetModal(context.MainForm.Handle, true);
+                               }
                        } else {
                                toplevels = null;
                        }
@@ -553,6 +555,8 @@
 
                                Control old = context.MainForm;
 
+                               context.MainForm = null;
+
                                while (toplevels.Count>0) {
                                        #if DebugRunLoop
                                                Console.WriteLine("      
Re-Enabling form form {0}", toplevels.Peek());
@@ -560,13 +564,13 @@
                                        c = (Control)toplevels.Dequeue();
                                        if (c.IsHandleCreated) {
                                                
XplatUI.EnableWindow(c.window.Handle, true);
-                                               
Application.MWFThread.Current.Context.MainForm = (Form)c;
+                                               context.MainForm = (Form)c;
                                        }
                                }
                                #if DebugRunLoop
                                        Console.WriteLine("   Done with the 
re-enable");
                                #endif
-                               if (context.MainForm.IsHandleCreated) {
+                               if (context.MainForm != null && 
context.MainForm.IsHandleCreated) {
                                        
XplatUI.SetModal(context.MainForm.Handle, false);
                                }
                                #if DebugRunLoop

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ApplicationContext.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ApplicationContext.cs
    2006-10-30 23:29:15 UTC (rev 67160)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ApplicationContext.cs
    2006-10-30 23:31:37 UTC (rev 67161)
@@ -58,7 +58,9 @@
                                                main_form.HandleDestroyed -= 
new EventHandler(OnMainFormClosed);
                                        }
                                        main_form = value;
-                                       main_form.HandleDestroyed += new 
EventHandler(OnMainFormClosed);
+                                       if (main_form != null) {
+                                               main_form.HandleDestroyed += 
new EventHandler(OnMainFormClosed);
+                                       }
                                }
                        }
                }

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-10-30 23:29:15 UTC (rev 67160)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-10-30 23:31:37 UTC (rev 67161)
@@ -1,5 +1,12 @@
 2006-10-30  Chris Toshok  <[EMAIL PROTECTED]>
 
+       * ApplicationContext.cs: guard against a NRE.
+
+       * Application.cs: null out the old MainForm for the context, so we
+       don't try to use it again once it's disposed.  Fixes bug #79783.
+
+2006-10-30  Chris Toshok  <[EMAIL PROTECTED]>
+
        * DataGrid.cs (set_DataSource, set_DataMember): if we have a
        BindingContext, set the data source directly, otherwise do the
        lazy approach - the actual ListManager will be created when we get

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to