summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaarten Bosmans <mkbosmans@gmail.com>2010-08-23 10:54:41 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2010-08-23 10:54:41 +0200
commit9713ead713201f10c0fe4185bc8bb0df4c276cc3 (patch)
treed9aebb7c5e8d736921147cbabb41c03bd1d88b2a
parent721340c32d93558071e00e2f96e4163f7e98d7aa (diff)
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.
-rw-r--r--gstreamer-sharp/Caps.custom3
-rw-r--r--tests/CapsTest.cs13
2 files changed, 15 insertions, 1 deletions
diff --git a/gstreamer-sharp/Caps.custom b/gstreamer-sharp/Caps.custom
index de2e255..4ff992d 100644
--- a/gstreamer-sharp/Caps.custom
+++ b/gstreamer-sharp/Caps.custom
@@ -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") ]
diff --git a/tests/CapsTest.cs b/tests/CapsTest.cs
index 826098c..f0e25a4 100644
--- a/tests/CapsTest.cs
+++ b/tests/CapsTest.cs
@@ -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);
+ }
}