2007-03-19 Chris Toshok <toshok@ximian.com>
authorChris Toshok <toshok@novell.com>
Tue, 20 Mar 2007 05:23:28 +0000 (05:23 -0000)
committerChris Toshok <toshok@novell.com>
Tue, 20 Mar 2007 05:23:28 +0000 (05:23 -0000)
* Control.cs (WmPaint): don't make use of the Handle property
after an event is emitted, as the user could have closed the
form/destroyed the control.  Store the Handle in a local variable
and make use of that.  Fixes bug #80768.

svn path=/trunk/mcs/; revision=74662

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs

index 8099a043cf2d46b4a8083d69d1d2880bf9882c15..70f99d8b64c9b1e80fc8e79e4fe390482f09da58 100644 (file)
@@ -1,3 +1,10 @@
+2007-03-19  Chris Toshok  <toshok@ximian.com>
+
+       * Control.cs (WmPaint): don't make use of the Handle property
+       after an event is emitted, as the user could have closed the
+       form/destroyed the control.  Store the Handle in a local variable
+       and make use of that.  Fixes bug #80768.
+
 2007-03-20  Everaldo Canuto  <everaldo@simios.org>
 
        * XplatUIX11.cs: Set _NET_WM_STATE_ABOVE on SetTopmost, it fixes Topmost
index ab036f969f5efa658a0fd004c91a7ffa02c9d783..e8260e09c8264485c276354d9031a1797c6a97f7 100644 (file)
@@ -4643,33 +4643,35 @@ namespace System.Windows.Forms
                private void WmPaint (ref Message m) {
                        PaintEventArgs  paint_event;
 
-                       paint_event = XplatUI.PaintEventStart(Handle, true);
+                       IntPtr handle = Handle;
 
-                       if (paint_event == null) {
+                       paint_event = XplatUI.PaintEventStart (handle, true);
+
+                       if (paint_event == null)
                                return;
-                       }
+
                        DoubleBuffer current_buffer = null;
                        if (UseDoubleBuffering) {
                                current_buffer = GetBackBuffer ();
                                if (!current_buffer.InvalidRegion.IsVisible (paint_event.ClipRectangle)) {
                                        // Just blit the previous image
                                        current_buffer.Blit (paint_event);
-                                       XplatUI.PaintEventEnd (Handle, true);
+                                       XplatUI.PaintEventEnd (handle, true);
                                        return;
                                }
                                current_buffer.Start (paint_event);
                        }
                                
                        if (!GetStyle(ControlStyles.Opaque)) {
-                               OnPaintBackground(paint_event);
+                               OnPaintBackground (paint_event);
                        }
 
                        // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
-                       OnPaintBackgroundInternal(paint_event);
+                       OnPaintBackgroundInternal (paint_event);
 
                        OnPaintInternal(paint_event);
                        if (!paint_event.Handled) {
-                               OnPaint(paint_event);
+                               OnPaint (paint_event);
                        }
 
                        if (current_buffer != null) {
@@ -4677,8 +4679,7 @@ namespace System.Windows.Forms
                        }
 
 
-                       XplatUI.PaintEventEnd(Handle, true);
-
+                       XplatUI.PaintEventEnd (handle, true);
                }
 
                private void WmEraseBackground (ref Message m) {