Gst.Object: use 'using' pattern for GValue
authorStephan Sundermann <stephansundermann@gmail.com>
Thu, 10 Oct 2013 20:50:34 +0000 (22:50 +0200)
committerStephan Sundermann <stephansundermann@gmail.com>
Sat, 21 Dec 2013 15:52:21 +0000 (16:52 +0100)
sources/custom/Object.cs

index be3c70c..1339002 100644 (file)
@@ -48,18 +48,17 @@ namespace Gst {
                public object this[string property] {
                  get {
                                if (PropertyExists (property)) {
-                                       GLib.Value v = GetProperty (property);
-                                       object o = v.Val;
-                                       v.Dispose ();
-                                       return o;
+                                       using (GLib.Value v = GetProperty (property)) {
+                                               return v.Val;
+                                       }
                                } else
                                        throw new PropertyNotFoundException ();
                  } set {
                                if (PropertyExists (property)) {
-                                       GLib.Value v = new GLib.Value (this, property);
-                                       v.Val = value;
-                                       SetProperty (property, v);
-                                       v.Dispose ();
+                                       using (GLib.Value v = new GLib.Value (this, property)) {
+                                               v.Val = value;
+                                               SetProperty (property, v);
+                                       }
                                } else
                                        throw new PropertyNotFoundException ();
                  }