gnomemm r1382 - in gstreamermm/trunk: . gstreamer/src



Author: jaalburqu
Date: Tue Mar  4 01:16:31 2008
New Revision: 1382
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1382&view=rev

Log:
2008-03-03  Josà Alburquerque  <jaalburqu svn gnome org>

	* gstreamer/src/element.ccg: Added GWeakNotify callback which will be
	called for each ElementInterfaced instance to delete them
	* gstreamer/src/element.hg: Modified constructor of ElementInterfaced
	to add a weak ref to underlying GObject; Added destructor to remove
	reference to underlying GObject so that the GObject is not "mangled"
	when ElementInterfaced is destroyed

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/element.ccg
   gstreamermm/trunk/gstreamer/src/element.hg

Modified: gstreamermm/trunk/gstreamer/src/element.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/element.ccg	Tue Mar  4 01:16:31 2008
@@ -36,6 +36,12 @@
 namespace Gst
 {
 
+void ElementInterfaced_WeakNotify_gstreamermm_callback(gpointer data,
+GObject* where_the_object_was)
+{
+  delete (Gst::Element*) data;
+}
+
 Glib::RefPtr<Element>
 Element::link(const Glib::RefPtr<Element>& other_element)
 {

Modified: gstreamermm/trunk/gstreamer/src/element.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/element.hg	Tue Mar  4 01:16:31 2008
@@ -179,6 +179,9 @@
 : public Element,
   public T_Interface
 {
+public:
+  virtual ~ElementInterfaced();
+
 protected:
   ElementInterfaced(const ElementInterfaced&);
   ElementInterfaced& operator=(const ElementInterfaced&);
@@ -192,11 +195,23 @@
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 
+void ElementInterfaced_WeakNotify_gstreamermm_callback(gpointer data, GObject* where_the_object_was);
+
 template <class T_Interface>
 ElementInterfaced<T_Interface>::ElementInterfaced(GstElement* castitem)
 {
   gobject_ = (GObject*)castitem;
   gst_object_ref(Element::gobj());
+  g_object_weak_ref(gobject_,
+    &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
+}
+
+template <class T_Interface>
+ElementInterfaced<T_Interface>::~ElementInterfaced()
+{
+  // Set the gobject_ to NULL so that when this is deleted, the gobject doesn't
+  // go with it and other elements "wrapping" the gobject are not affected
+  gobject_ = 0;
 }
 
 #endif /* DOXYGEN_SHOULD_SKIP_THIS */



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