[hyena/gtk3] Replace a couple of IDisposable casts/calls with using{} blocks syntax



commit 650ddcb0e9eb88d51fbaca7b8b0733cff1c17352
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Sat Aug 24 14:07:32 2013 +0200

    Replace a couple of IDisposable casts/calls with using{} blocks syntax

 Hyena.Gui/Hyena.Gui/CairoExtensions.cs    |    8 ++++----
 Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs |   16 ++++++++--------
 2 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Gui/CairoExtensions.cs b/Hyena.Gui/Hyena.Gui/CairoExtensions.cs
index 4012b5e..5b29b3c 100644
--- a/Hyena.Gui/Hyena.Gui/CairoExtensions.cs
+++ b/Hyena.Gui/Hyena.Gui/CairoExtensions.cs
@@ -69,10 +69,10 @@ namespace Hyena.Gui
         {
             var target = cr.GetTarget ();
             Surface surface = target.CreateSimilar (target.Content, pixbuf.Width, pixbuf.Height);
-            Cairo.Context surface_cr = new Context (surface);
-            Gdk.CairoHelper.SetSourcePixbuf (surface_cr, pixbuf, 0.0, 0.0);
-            surface_cr.Paint ();
-            ((IDisposable)surface_cr).Dispose ();
+            using (var surface_cr = new Context (surface)) {
+                Gdk.CairoHelper.SetSourcePixbuf (surface_cr, pixbuf, 0.0, 0.0);
+                surface_cr.Paint ();
+            }
             return surface;
         }
 
diff --git a/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs b/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs
index becd51b..ff77cf3 100644
--- a/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs
+++ b/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs
@@ -99,16 +99,16 @@ namespace Hyena.Widgets
 
             // Copy the widget's pixels to surface, we'll use it to draw the animation
             surface = Window.CreateSimilarSurface (Cairo.Content.ColorAlpha, widget_alloc.Width, 
widget_alloc.Height);
-            var cr = new Cairo.Context (surface);
-            Gdk.CairoHelper.SetSourceWindow (cr, Window, widget_alloc.X, widget_alloc.Y);
-            cr.Rectangle (0, 0, widget_alloc.Width, widget_alloc.Height);
-            cr.Fill ();
+            using (var cr = new Cairo.Context (surface)) {
+                Gdk.CairoHelper.SetSourceWindow (cr, Window, widget_alloc.X, widget_alloc.Y);
+                cr.Rectangle (0, 0, widget_alloc.Width, widget_alloc.Height);
+                cr.Fill ();
 
-            if (AnimationState != AnimationState.Going) {
-                WidgetDestroyed (this, args);
-            }
+                if (AnimationState != AnimationState.Going) {
+                    WidgetDestroyed (this, args);
+                }
 
-            ((IDisposable)cr).Dispose ();
+            }
         }
 
 #region Overrides


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]