[pitivi] factories: Fix leak introduce by one of my previous commit



commit 18a17dbd2bd59175d4a3a0458dd221f9fd79b043
Author: Edward Hervey <bilboed bilboed com>
Date:   Thu Jun 11 18:38:17 2009 +0200

    factories: Fix leak introduce by one of my previous commit

 pitivi/factories/base.py |   19 ++++++++++++++++++-
 pitivi/factories/file.py |   10 ++++++++++
 2 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/pitivi/factories/base.py b/pitivi/factories/base.py
index 240bdf7..20aebd3 100644
--- a/pitivi/factories/base.py
+++ b/pitivi/factories/base.py
@@ -261,6 +261,7 @@ class SourceFactory(ObjectFactory):
         """
         bin.set_state(gst.STATE_NULL)
         self._releaseBin(bin)
+        self.debug("Finally releasing %r", bin)
         self.current_bins -= 1
         if bin in self.bins:
             self.bins.remove(bin)
@@ -583,6 +584,19 @@ class URISourceFactoryMixin(object):
         ghost_pad = bin.get_pad(pad.get_name())
         bin.remove_pad(ghost_pad)
 
+    def _releaseBin(self, bin):
+        if hasattr(bin, "dbin"):
+            self.debug("has dbin")
+            bin.dbin.disconnect_by_func(self._singlePadAddedCb)
+            bin.dbin.disconnect_by_func(self._singlePadRemovedCb)
+            del bin.dbin
+        if hasattr(bin, "volume"):
+            bin.volume.set_state(gst.STATE_NULL)
+            bin.remove(bin.volume)
+            del bin.volume
+        if hasattr(bin, "ghostpad"):
+            del bin.ghostpad
+
     def _makeStreamBin(self, output_stream):
         self.debug("output_stream:%r", output_stream)
         b = gst.Bin()
@@ -613,9 +627,12 @@ class URISourceFactoryMixin(object):
     def _singlePadRemovedCb(self, dbin, pad, topbin):
         self.debug("dbin:%r, pad:%r, topbin:%r", dbin, pad, topbin)
         topbin.remove_pad(topbin.ghostpad)
-        topbin.ghostpad = None
+        del topbin.ghostpad
         if hasattr(topbin, "volume"):
             pad.unlink(topbin.volume.get_pad("sink"))
+            topbin.volume.set_state(gst.STATE_NULL)
+            topbin.remove(topbin.volume)
+            del topbin.volume
 
 class LiveURISourceFactory(URISourceFactoryMixin, LiveSourceFactory):
     """
diff --git a/pitivi/factories/file.py b/pitivi/factories/file.py
index 0f62ae8..1adc4a9 100644
--- a/pitivi/factories/file.py
+++ b/pitivi/factories/file.py
@@ -51,6 +51,7 @@ class FileSourceFactory(URISourceFactoryMixin, RandomAccessSourceFactory):
                 bin.decodebin.disconnect_by_func(self._dbinPadRemovedCb)
             except:
                 pass
+        URISourceFactoryMixin._releaseBin(self, bin)
         RandomAccessSourceFactory._releaseBin(self, bin)
 
 class PictureFileSourceFactory(FileSourceFactory):
@@ -110,6 +111,15 @@ class PictureFileSourceFactory(FileSourceFactory):
         container.remove_pad(ghost)
         pad.unlink(scale.get_pad("sink"))
 
+    def _releaseBin(self, bin):
+        if hasattr(bin, "decodebin"):
+            try:
+                bin.decodebin.disconnect_by_func(self._dbinPadAddedCb)
+                bin.decodebin.disconnect_by_func(self._dbinPadRemovedCb)
+            except:
+                pass
+        FileSourceFactory._releaseBin(self, bin.decodebin)
+
 class URISinkFactory(SinkFactory):
     """ A simple sink factory """
 



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