gnomemm r1801 - in gstreamermm/trunk: . gstreamer/src gstreamerbase/src



Author: jaalburqu
Date: Tue Nov 18 22:34:12 2008
New Revision: 1801
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1801&view=rev

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

	* gstreamer/src/task.ccg:
	* gstreamer/src/task.hg: Used _WRAP_CREATE() to generate create()
	method.
	* gstreamerbase/src/audioclock.ccg:
	* gstreamerbase/src/audioclock.hg: Modified both Gst::Task and
	GstBase::AudioClock to keep track if a slot was created so that if one
	has not been created (because an object was wrapped and not created)
	the delete statement is is not called in the destructor.

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/task.ccg
   gstreamermm/trunk/gstreamer/src/task.hg
   gstreamermm/trunk/gstreamerbase/src/audioclock.ccg
   gstreamermm/trunk/gstreamerbase/src/audioclock.hg

Modified: gstreamermm/trunk/gstreamer/src/task.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/task.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/task.ccg	Tue Nov 18 22:34:12 2008
@@ -44,22 +44,36 @@
 namespace Gst
 {
 
-Glib::RefPtr<Task> Task::create(const SlotTask& slot)
+Task::Task(const SlotTask& task_slot)
+: _CONSTRUCT()
 {
   //Create a copy of the slot.  A pointer to this copy will be passed through
   //the call back's data parameter.  It will be destroyed in the Task's
   //destructor
-  SlotTask *slot_copy = new SlotTask(slot);
+  slot = new SlotTask(task_slot);
+  _slot_set(true);
 
-  Glib::RefPtr<Task> task = Glib::wrap(gst_task_create(&Task_Task_gstreamermm_callback, slot_copy));
-  task->slot = slot_copy;
-  return task;
+  // These lines are taken verbatim from gst_task_create() after calling
+  // g_object_new().
+  gobj()->func = &Task_Task_gstreamermm_callback;
+  gobj()->data = &slot;
+}
+
+bool Task::_slot_set(bool mark_set)
+{
+  static bool slot_set = false;
+
+  if (mark_set)
+    slot_set = true;
+
+  return slot_set;
 }
 
 Task::~Task()
 {
   // Delete task's slot upon destruction
-  delete this->slot;
+  if (_slot_set())
+    delete slot;
 }
 
 } //namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/task.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/task.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/task.hg	Tue Nov 18 22:34:12 2008
@@ -70,16 +70,20 @@
    */
   typedef sigc::slot<void> SlotTask;
 
+protected:
+  Task(const SlotTask& task_slot);
+
+public:
   /** Create a new Gst::Task that will repeadedly call the provided slot as a
    * parameter. Typically the task will run in a new thread.
    *
    * The slot cannot be changed after the task has been created. You must
    * create a new Gst::Task to change the slot.
    *
-   * @param slot The Gst::Task::SlotTask to use.
+   * @param task_slot The Gst::Task::SlotTask to use.
    * @return A new Gst::Task. MT safe.
    */
-  static Glib::RefPtr<Task> create(const SlotTask& slot);
+  _WRAP_CREATE(const SlotTask& task_slot);
 
   _WRAP_METHOD(static void cleanup_all(), gst_task_cleanup_all)
   _WRAP_METHOD(TaskState get_state(), gst_task_get_state)
@@ -92,6 +96,7 @@
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 private:
   SlotTask* slot;
+  bool _slot_set(bool mark_set = false);
 #endif
 };
 

Modified: gstreamermm/trunk/gstreamerbase/src/audioclock.ccg
==============================================================================
--- gstreamermm/trunk/gstreamerbase/src/audioclock.ccg	(original)
+++ gstreamermm/trunk/gstreamerbase/src/audioclock.ccg	Tue Nov 18 22:34:12 2008
@@ -50,6 +50,7 @@
   : _CONSTRUCT("name", name.c_str())
 {
   slot = new SlotGetTime(time_slot);
+  _slot_set(true);
 
   //The following lines are taken verbatim from gst_audio_clock_new() after the
   //call to g_object_new() because it seems that bug #545782 will not be
@@ -58,10 +59,21 @@
   gobj()->user_data = &slot;
 }
 
+bool AudioClock::_slot_set(bool mark_set)
+{
+  static bool slot_set = false;
+
+  if (mark_set)
+    slot_set = true;
+
+  return slot_set;
+}
+
+
 AudioClock::~AudioClock()
 {
-  delete slot;
+  if (_slot_set())
+    delete slot;
 }
 
 } //namespace GstBase
-

Modified: gstreamermm/trunk/gstreamerbase/src/audioclock.hg
==============================================================================
--- gstreamermm/trunk/gstreamerbase/src/audioclock.hg	(original)
+++ gstreamermm/trunk/gstreamerbase/src/audioclock.hg	Tue Nov 18 22:34:12 2008
@@ -69,6 +69,7 @@
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 private:
   SlotGetTime* slot;
+  bool _slot_set(bool mark_set = false);
 #endif
 };
 



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