From 3a2d6750f193c84643a32c3ffe66cba6b7853292 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Sat, 12 Oct 2013 16:47:10 +0200 Subject: [PATCH] Iterator: Try resetting value before usage --- sources/custom/Iterator.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sources/custom/Iterator.cs b/sources/custom/Iterator.cs index b5ee3b220b..6ed07b7345 100644 --- a/sources/custom/Iterator.cs +++ b/sources/custom/Iterator.cs @@ -31,6 +31,9 @@ namespace Gst { public partial class Iterator : IEnumerable { + [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr g_value_reset (ref GLib.Value val); + private class Enumerator : IEnumerator { Iterator iterator; Hashtable seen = new Hashtable (); @@ -50,7 +53,10 @@ namespace Gst { return false; do { - GLib.Value value; + GLib.Value value = new GLib.Value (); + IntPtr ptr = g_value_reset (ref value); + value = (GLib.Value) Marshal.PtrToStructure (ptr, typeof(GLib.Value)); + IteratorResult ret = iterator.Next (out value); switch (ret) { @@ -70,7 +76,7 @@ namespace Gst { break; default: case IteratorResult.Error: - throw new Exception ("Error while iterating pads"); + throw new Exception ("Error while iterating"); } } while (retry);