[winforms] Fix graphics leak
authorRalph Leckett <rleckett@gmail.com>
Sat, 11 Dec 2010 04:02:51 +0000 (23:02 -0500)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 11 Dec 2010 04:02:51 +0000 (23:02 -0500)
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs

index e9dd8e62bf5eec8b6d2a1e6430097a5d138ac968..1a68cc083128ba4d0264f43c5bbb90a9a20077af 100644 (file)
@@ -27,7 +27,6 @@
 using System.Collections;
 using System.Drawing;
 using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
 using System.Reflection;
 
 namespace System.Windows.Forms
index fe40ba3ee8bc79793cb9cf596f9c3e0dbef6187a..9696364924c565ec22facca14158e007b271cade 100644 (file)
@@ -60,7 +60,8 @@ namespace System.Windows.Forms
                        ia.SetColorMatrix (grayscale_matrix);
                        
                        Bitmap b = new Bitmap(normalImage.Width, normalImage.Height);
-                       Graphics.FromImage(b).DrawImage(normalImage, new Rectangle (0, 0, normalImage.Width, normalImage.Height), 0, 0, normalImage.Width, normalImage.Height, GraphicsUnit.Pixel, ia);
+                       using (Graphics g = Graphics.FromImage(b))
+                               g.DrawImage(normalImage, new Rectangle (0, 0, normalImage.Width, normalImage.Height), 0, 0, normalImage.Width, normalImage.Height, GraphicsUnit.Pixel, ia);
                        
                        return b;
                }