Don't modify hash tables while iterating over them

This caused crashes for caps with more than a single struct
when unreffing them in one way or another.

Fixes bug #627677.
This commit is contained in:
Maarten Bosmans 2010-08-23 10:54:41 +02:00 committed by Sebastian Dröge
parent 721340c32d
commit 9713ead713
2 changed files with 15 additions and 1 deletions

View file

@ -57,8 +57,9 @@ private void RemoveStructureReference (Structure s) {
private void RemoveStructureReferences () {
foreach (Structure s in structures.Values) {
RemoveStructureReference (s);
s.CreateNativeCopy ();
}
structures.Clear ();
}
[DllImport ("libgstreamer-0.10.dll") ]

View file

@ -10,6 +10,7 @@
using System;
using NUnit.Framework;
using Gst;
using Gst.Video;
[TestFixture]
public class CapsTest {
@ -91,4 +92,16 @@ public class CapsTest {
"height=(int)480");
Assert.IsTrue (caps3.IsEqual (caps4));
}
[Test]
public void TestManagedReferences() {
Caps tmp = VideoUtil.FormatToTemplateCaps(Gst.Video.VideoFormat.RGBX);
Caps caps = tmp.Copy();
caps[0]["width"] = 640;
caps[0]["height"] = 480;
caps.Append(tmp);
Caps any = Caps.NewAny();
caps.Merge(any);
}
}