* System.Windows.Forms/XplatUIWin32.cs: Don't call Win32GetLastError
authorRolf Bjarne Kvinge <RKvinge@novell.com>
Fri, 17 Aug 2007 07:01:04 +0000 (07:01 -0000)
committerRolf Bjarne Kvinge <RKvinge@novell.com>
Fri, 17 Aug 2007 07:01:04 +0000 (07:01 -0000)
  directly, use Marshal.GetLastWin32Error. Plug nasty memory leak in
  PaintEventStart/End, we were creating a DC we weren't releasing.

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

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

index d581c72ee638abbe12b0af33efddfa69953083d0..77bd16b979ddc7d06c15b26396d27934aa43839e 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-17  Rolf Bjarne Kvinge <RKvinge@novell.com> 
+
+       * XplatUIWin32.cs: Don't call Win32GetLastError directly, use
+         Marshal.GetLastWin32Error. Plug nasty memory leak in
+         PaintEventStart/End, we were creating a DC we weren't releasing.
+
 2007-08-17  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * ListView.cs: Add Groups support in Details view. Also have a small
index ff74e8018d867de11d9d024de26ddd4662f33085..2cb4220a476217ec5bdd3d8b08144392293011de 100644 (file)
@@ -1581,7 +1581,7 @@ namespace System.Windows.Forms {
                        HwndCreating = null;
 
                        if (WindowHandle==IntPtr.Zero) {
-                               uint error = Win32GetLastError();
+                               int error = Marshal.GetLastWin32Error ();
 
                                Win32MessageBox(IntPtr.Zero, "Error : " + error.ToString(), "Failed to create window, class '"+cp.ClassName+"'", 0);
                        }
@@ -1756,9 +1756,8 @@ namespace System.Windows.Forms {
                                        clip_rect = new Rectangle(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right-ps.rcPaint.left, ps.rcPaint.bottom-ps.rcPaint.top);
                                } else {
                                        hdc = Win32GetDC(handle);
-                                       // FIXME: Add the DC to internal list
 
-                                       hwnd.drawing_stack.Push (null);
+                                       hwnd.drawing_stack.Push (hdc);
 
                                        clip_rect = new Rectangle(rect.top, rect.left, rect.right-rect.left, rect.bottom-rect.top);
                                }
@@ -1791,8 +1790,13 @@ namespace System.Windows.Forms {
                        if (client) {
                                object o = hwnd.drawing_stack.Pop();
                                if (o != null) {
-                                       PAINTSTRUCT ps = (PAINTSTRUCT)o;
-                                       Win32EndPaint(handle, ref ps);
+                                       if (o is PAINTSTRUCT) {
+                                               PAINTSTRUCT ps = (PAINTSTRUCT)o;
+                                               Win32EndPaint(handle, ref ps);
+                                       } else if (o is IntPtr) {
+                                               IntPtr hdc = (IntPtr) o;
+                                               Win32ReleaseDC (handle, hdc);
+                                       }
                                }
                        } else {
                                IntPtr hdc = (IntPtr)hwnd.drawing_stack.Pop();