diff --git a/src/bindings/mono/eina_mono/eina_accessor.cs b/src/bindings/mono/eina_mono/eina_accessor.cs index 2fb8437efd..0bb3b788f3 100644 --- a/src/bindings/mono/eina_mono/eina_accessor.cs +++ b/src/bindings/mono/eina_mono/eina_accessor.cs @@ -150,29 +150,18 @@ public class Accessor : IEnumerable, IDisposable /// An enumerator to walk through the acessor items. public IEnumerator GetEnumerator() { -/* if (Handle == IntPtr.Zero) { throw new ObjectDisposedException(base.GetType().Name); } - IntPtr tmp = MemoryNative.Alloc(Marshal.SizeOf(typeof(IntPtr))); + IntPtr tmp; uint position = 0; - try + while (eina_accessor_data_get(Handle, position, out tmp)) { - while (eina_accessor_data_get(Handle, position, tmp)) - { - IntPtr data = (IntPtr)Marshal.PtrToStructure(tmp, typeof(IntPtr)); - yield return Convert(data); - position += 1; - } + yield return Convert(tmp); // No need to free as it is still owned by the container. + position += 1; } - finally - { - MemoryNative.Free(tmp); - } -*/ - yield break; } IEnumerator IEnumerable.GetEnumerator() diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs index 46d89e4c55..638a65ce58 100644 --- a/src/tests/efl_mono/Eina.cs +++ b/src/tests/efl_mono/Eina.cs @@ -4577,6 +4577,9 @@ class TestEinaAccessor Test.AssertEquals(pair.Item1, pair.Item2); } + IEnumerable seq = accessor; + Test.AssertEquals(seq.Count(), 4); + lst.Dispose(); }