diff --git a/ChangeLog b/ChangeLog index 4402b35dee..bc2683259a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-10-05 Thomas Vander Stichele + + * gst/gst-types.defs: + * gst/gstcaps.override: + * testsuite/test_caps.py: + add gst.Caps.__refcount__ + 2005-10-05 Thomas Vander Stichele * testsuite/test_pad.py: diff --git a/gst/gst-types.defs b/gst/gst-types.defs index 8dc5db2dba..5b544800b5 100644 --- a/gst/gst-types.defs +++ b/gst/gst-types.defs @@ -203,6 +203,9 @@ (in-module "Gst") (c-name "GstCaps") (gtype-id "GST_TYPE_CAPS") + (fields + '("int" "__refcount__") + ) ) (define-object Plugin diff --git a/gst/gstcaps.override b/gst/gstcaps.override index 565b7c8ccc..bd38b0fed8 100644 --- a/gst/gstcaps.override +++ b/gst/gstcaps.override @@ -419,6 +419,8 @@ _wrap_gst_caps_tp_dealloc (PyObject *self) if (boxed->free_on_dealloc && boxed->boxed) { pygst_caps_map_modified (self); + GST_DEBUG ("unreffing caps %" GST_PTR_FORMAT "with refcount %d", + boxed->boxed, GST_CAPS_REFCOUNT (boxed->boxed)); gst_caps_unref (boxed->boxed); } @@ -438,3 +440,13 @@ _wrap_gst_caps_tp_str(PyGObject *self) return retval; } + +%% +override-attr GstCaps.__refcount__ + +static PyObject * +_wrap_gst_caps__get___refcount__(PyGObject *self, void *closure) +{ + return PyInt_FromLong(GST_CAPS_REFCOUNT(self->obj)); +} + diff --git a/testsuite/test_caps.py b/testsuite/test_caps.py index c6810a7b31..97a2a4a667 100644 --- a/testsuite/test_caps.py +++ b/testsuite/test_caps.py @@ -26,9 +26,12 @@ from common import gst, unittest class CapsTest(unittest.TestCase): def setUp(self): self.caps = gst.caps_from_string('video/x-raw-yuv,width=10,framerate=5.0;video/x-raw-rgb,width=15,framerate=10.0') + self.assertEquals(self.caps.__refcount__, 1) self.structure = self.caps[0] self.any = gst.Caps("ANY") + self.assertEquals(self.any.__refcount__, 1) self.empty = gst.Caps() + self.assertEquals(self.empty.__refcount__, 1) def testCapsMime(self): mime = self.structure.get_name()