[gstreamermm] Gst::Caps: increase refcount in *_Boxed wrapper on getting value



commit 639e8e949021f1926204ef9023999d7b4f4b17dc
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Mon Jun 8 19:30:54 2015 +0200

    Gst::Caps: increase refcount in *_Boxed wrapper on getting value
    
        * gstreamer/src/caps.{ccg|hg}: increase refcount in get() method.
        * tests/test-caps.cc: add test.

 gstreamer/src/caps.ccg |    8 ++++++++
 gstreamer/src/caps.hg  |    2 +-
 tests/test-caps.cc     |   13 +++++++++++++
 3 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/gstreamer/src/caps.ccg b/gstreamer/src/caps.ccg
index 35ea123..d50cb5f 100644
--- a/gstreamer/src/caps.ccg
+++ b/gstreamer/src/caps.ccg
@@ -153,3 +153,11 @@ Glib::RefPtr<Gst::Caps> Caps::truncate()
 }
 
 } //namespace Gst
+
+namespace Glib 
+{
+Glib::RefPtr<Gst::Caps> Value< Glib::RefPtr<Gst::Caps> >::get()
+{
+  return Glib::wrap(reinterpret_cast<GstCaps*>(get_boxed()), true); 
+}
+}
diff --git a/gstreamer/src/caps.hg b/gstreamer/src/caps.hg
index 7d21c0b..de463f3 100644
--- a/gstreamer/src/caps.hg
+++ b/gstreamer/src/caps.hg
@@ -311,7 +311,7 @@ class Value< Glib::RefPtr<Gst::Caps> > : public ValueBase_Boxed
 public:
   static GType value_type() { return Gst::Caps::get_type(); }
   void set(const Glib::RefPtr<Gst::Caps>& caps) { set_boxed(Glib::unwrap(caps)); }
-  Glib::RefPtr<Gst::Caps> get()                 { return 
Glib::RefPtr<Gst::Caps>(reinterpret_cast<Gst::Caps*>(get_boxed())); }
+  Glib::RefPtr<Gst::Caps> get();
 };
 
 }
diff --git a/tests/test-caps.cc b/tests/test-caps.cc
index d35b0bd..ba05d4f 100644
--- a/tests/test-caps.cc
+++ b/tests/test-caps.cc
@@ -121,3 +121,16 @@ TEST_F(CapsTest, MergeCaps)
     ASSERT_EQ(1, tmp->get_refcount());
     ASSERT_FALSE(tmp2);
 }
+
+TEST_F(CapsTest, CapsBoxedType)
+{
+    Glib::RefPtr<Gst::CapsFilter> filter = Gst::CapsFilter::create();
+    Glib::RefPtr<Gst::Caps> any_caps = Gst::Caps::create_any();
+    Glib::RefPtr<Gst::Caps> any_caps2 = Gst::Caps::create_any();
+    ASSERT_EQ(1, any_caps->get_refcount());
+    filter->property_caps() = any_caps;
+    ASSERT_EQ(2, any_caps->get_refcount());
+    filter->property_caps() = any_caps2;
+    ASSERT_EQ(1, any_caps->get_refcount());
+    ASSERT_EQ(2, any_caps2->get_refcount());
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]