]> git.sesse.net Git - kdenlive/commitdiff
[valgrind] unfixed memleak
authorRay Lehtiniemi <rayl@mail.com>
Fri, 10 Apr 2009 14:44:20 +0000 (14:44 +0000)
committerRay Lehtiniemi <rayl@mail.com>
Fri, 10 Apr 2009 14:44:20 +0000 (14:44 +0000)
Signed-off-by: Ray Lehtiniemi <rayl@mail.com>
svn path=/trunk/kdenlive/; revision=3274

src/kthumb.cpp
src/renderer.cpp

index c92f72d4f51a4d187cc39c18ae773e29ef94d3d2..dbbe01e3a5a95f6b9f0116c1f4477f247b857566 100644 (file)
@@ -146,6 +146,8 @@ KThumb::~KThumb()
 void KThumb::setProducer(Mlt::Producer *producer)
 {
     m_producer = producer;
+    // FIXME: the profile() call leaks an object, but trying to free
+    // it leads to a double-free in Profile::~Profile()
     m_dar = producer->profile()->dar();
 }
 
index 89144b022ce65669507a8e98550431036a3105ce..ab45295d0e75f6fedda923f5dab4b925cbe0bb98 100644 (file)
@@ -132,8 +132,11 @@ void Render::buildConsumer()
     m_mltConsumer->set("resize", 1);
     m_mltConsumer->set("window_id", m_winid);
     m_mltConsumer->set("terminate_on_pause", 1);
-    m_mltConsumer->set("window_background", decodedString(KdenliveSettings::window_background().name()));
+    tmp = decodedString(KdenliveSettings::window_background().name());
+    m_mltConsumer->set("window_background", tmp);
+    delete [] tmp;
 
+    // FIXME: the event object returned by the listen gets leaked...
     m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
     m_mltConsumer->set("rescale", "nearest");
 
@@ -523,6 +526,7 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId, bo
     if (producer == NULL || producer->is_blank() || !producer->is_valid()) {
         kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: ";
         emit removeInvalidClip(clipId);
+        delete producer;
         return;
     }
 
@@ -639,6 +643,7 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId, bo
         /*if (context->duration == AV_NOPTS_VALUE) {
         kDebug() << " / / / / / / / /ERROR / / / CLIP HAS UNKNOWN DURATION";
             emit removeInvalidClip(clipId);
+            delete producer;
             return;
         }*/
         // Get the video_index
@@ -710,6 +715,7 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId, bo
     emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap, replaceProducer);
     kDebug() << "REquested fuile info for: " << url.path();
     if (frame) delete frame;
+    // FIXME: should delete this to avoid a leak...
     //if (producer) delete producer;
 }
 
@@ -966,6 +972,7 @@ void Render::connectPlaylist()
     /*
      if (m_mltConsumer->start() == -1) {
           KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
+          delete m_mltConsumer;
           m_mltConsumer = NULL;
      }
      else {
@@ -1034,6 +1041,7 @@ void Render::start()
         kDebug() << "-----  MONITOR: " << m_name << " WAS STOPPED";
         if (m_mltConsumer->start() == -1) {
             KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
+            delete m_mltConsumer;
             m_mltConsumer = NULL;
             return;
         } else {
@@ -2860,18 +2868,22 @@ QList <Mlt::Producer *> Render::producersList()
 
     int trackNb = tractor.count();
     for (int t = 1; t < trackNb; t++) {
-        Mlt::Producer trackProducer(tractor.track(t));
+        Mlt::Producer *tt = tractor.track(t);
+        Mlt::Producer trackProducer(tt);
+        delete tt;
         Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
         int clipNb = trackPlaylist.count();
         //kDebug() << "// PARSING SCENE TRACK: " << t << ", CLIPS: " << clipNb;
         for (int i = 0; i < clipNb; i++) {
-            Mlt::Producer *nprod = new Mlt::Producer(trackPlaylist.get_clip(i)->get_parent());
+            Mlt::Producer *c = trackPlaylist.get_clip(i);
+            Mlt::Producer *nprod = new Mlt::Producer(c->get_parent());
             if (nprod) {
                 if (!nprod->is_blank() && !ids.contains(nprod->get("id"))) {
                     ids.append(nprod->get("id"));
                     prods.append(nprod);
                 } else delete nprod;
             }
+            delete c;
         }
     }
     return prods;
@@ -2886,11 +2898,14 @@ void Render::fillSlowMotionProducers()
 
     int trackNb = tractor.count();
     for (int t = 1; t < trackNb; t++) {
-        Mlt::Producer trackProducer(tractor.track(t));
+        Mlt::Producer *tt = tractor.track(t);
+        Mlt::Producer trackProducer(tt);
+        delete tt;
         Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
         int clipNb = trackPlaylist.count();
         for (int i = 0; i < clipNb; i++) {
-            Mlt::Producer *nprod = new Mlt::Producer(trackPlaylist.get_clip(i)->get_parent());
+            Mlt::Producer *c = trackPlaylist.get_clip(i);
+            Mlt::Producer *nprod = new Mlt::Producer(c->get_parent());
             if (nprod) {
                 QString id = nprod->get("id");
                 if (id.startsWith("slowmotion:") && !nprod->is_blank()) {
@@ -2901,6 +2916,7 @@ void Render::fillSlowMotionProducers()
                     }
                 } else delete nprod;
             }
+            delete c;
         }
     }
 }