From: Ralph Leckett Date: Sat, 11 Dec 2010 04:02:51 +0000 (-0500) Subject: [winforms] Fix graphics leak X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=858dc2e7ec633fd6a5e249191fb77b0eef6dd35a;p=mono.git [winforms] Fix graphics leak --- diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs index e9dd8e62bf5..1a68cc08312 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs @@ -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 diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs index fe40ba3ee8b..9696364924c 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs @@ -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; }