]> git.sesse.net Git - kdenlive/commitdiff
Fix some more threading crashes, almost there :)
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 22 Oct 2011 22:49:41 +0000 (22:49 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 22 Oct 2011 22:49:41 +0000 (22:49 +0000)
svn path=/trunk/kdenlive/; revision=5980

src/docclipbase.cpp
src/docclipbase.h
src/kthumb.cpp
src/kthumb.h
src/projectlist.cpp
src/renderer.cpp

index b7fa0d20860e15dd894591d295d87bb91ee9d72b..4d3a3bf02bc3e344fa4877da3173547b0cbe6037 100644 (file)
@@ -163,11 +163,6 @@ const QString &DocClipBase::getId() const
     return m_id;
 }
 
-void DocClipBase::setId(const QString &newId)
-{
-    m_id = newId;
-}
-
 const CLIPTYPE & DocClipBase::clipType() const
 {
     return m_clipType;
@@ -653,7 +648,7 @@ Mlt::Producer *DocClipBase::getCloneProducer()
         prod = cloneProducer(source);
     }
     if (prod) {
-        adjustProducerProperties(prod, getId() + "_monitor", false, false);
+        adjustProducerProperties(prod, getId() + "_", false, false);
     }
     return prod;
 }
index 97a68693bdaf078f659ee2a0d0cabb4dd575bc29..337a137330dab5cd69de9316130f19eb1c682e35 100644 (file)
@@ -82,7 +82,6 @@ Q_OBJECT public:
 
     /** Returns the internal unique id of the clip. */
     const QString &getId() const;
-    void setId(const QString &newId);
 
     //KThumb *thumbCreator;
     bool audioThumbCreated() const;
index 71f2bfc96dc37d5a20d75f9a2110c28ee7377ff6..6eb212a7d358eac233f2e889edbb4a1037596601 100644 (file)
@@ -57,7 +57,9 @@ KThumb::KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QStr
 
 KThumb::~KThumb()
 {
+    m_listMutex.lock();
     m_requestedThumbs.clear();
+    m_listMutex.unlock();
     m_intraFramesQueue.clear();
     if (m_audioThumbProducer.isRunning()) {
         m_stopAudioThumbs = true;
@@ -70,7 +72,9 @@ KThumb::~KThumb()
 
 void KThumb::setProducer(Mlt::Producer *producer)
 {
+    m_listMutex.lock();
     m_requestedThumbs.clear();
+    m_listMutex.unlock();
     m_intraFramesQueue.clear();
     m_future.waitForFinished();
     m_intra.waitForFinished();
@@ -116,9 +120,11 @@ QPixmap KThumb::getImage(KUrl url, int width, int height)
 void KThumb::extractImage(int frame, int frame2)
 {
     if (!KdenliveSettings::videothumbnails() || m_producer == NULL) return;
+    m_listMutex.lock();
     if (frame != -1 && !m_requestedThumbs.contains(frame)) m_requestedThumbs.append(frame);
     if (frame2 != -1 && !m_requestedThumbs.contains(frame2)) m_requestedThumbs.append(frame2);
     qSort(m_requestedThumbs);
+    m_listMutex.unlock();
     if (!m_future.isRunning()) {
         m_future = QtConcurrent::run(this, &KThumb::doGetThumbs);
     }
@@ -131,7 +137,9 @@ void KThumb::doGetThumbs()
     const int dwidth = (int)(theight * m_dar + 0.5);
 
     while (!m_requestedThumbs.isEmpty()) {
+        m_listMutex.lock();
         int frame = m_requestedThumbs.takeFirst();
+        m_listMutex.unlock();
         if (frame != -1) {
             QImage img = getProducerFrame(frame, swidth, dwidth, theight);
             emit thumbReady(frame, img);
index dd23ed217aae972d658297c7877f829541447f79..f90051d7b43a8ea81ac91397fa7c325f41c38b70 100644 (file)
@@ -121,6 +121,7 @@ private:
     /** @brief List of frame numbers from which we want to extract thumbnails. */
     QList <int> m_intraFramesQueue;
     QMutex m_mutex;
+    QMutex m_listMutex;
     void doGetThumbs();
     QImage getProducerFrame(int framepos, int frameWidth, int displayWidth, int height);
 
index e798466b56dc2623949d3f37b5b5f297c62646d6..72a7acbb02efca47c40fc75d49a5c10b130e9602 100644 (file)
@@ -523,8 +523,8 @@ void ProjectList::slotReloadClip(const QString &id)
                     e.setAttribute("length", length);
                 }
             }
-            m_render->getFileProperties(e, item->clipId(), m_listView->iconSize().height(), true);
             resetThumbsProducer(clip);
+            m_render->getFileProperties(e, item->clipId(), m_listView->iconSize().height(), true);
         }
     }
 }
@@ -1085,8 +1085,8 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
         m_listView->processLayout();
         QDomElement e = clip->toXML().cloneNode().toElement();
         e.removeAttribute("file_hash");
-        m_render->getFileProperties(e, clip->getId(), m_listView->iconSize().height(), true);
         resetThumbsProducer(clip);
+        m_render->getFileProperties(e, clip->getId(), m_listView->iconSize().height(), true);
     }
     else if (item->hasProxy() && !item->isProxyRunning()) {
         slotCreateProxy(clip->getId());
@@ -1154,6 +1154,7 @@ void ProjectList::slotGotProxy(ProjectItem *item)
             e.setAttribute("length", length);
         }
     }
+    resetThumbsProducer(clip);
     m_render->getFileProperties(e, clip->getId(), m_listView->iconSize().height(), true);
 }
 
@@ -1237,8 +1238,8 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged)
                         xml.removeAttribute("proxy_out");
                     }
                     bool replace = xml.attribute("replace") == "1";
-                    m_render->getFileProperties(xml, clip->getId(), m_listView->iconSize().height(), replace);
                     if (replace) resetThumbsProducer(clip);
+                    m_render->getFileProperties(xml, clip->getId(), m_listView->iconSize().height(), replace);
                 }
                 else {
                     item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
@@ -1641,7 +1642,8 @@ void ProjectList::resetThumbsProducer(DocClipBase *clip)
 {
     if (!clip) return;
     clip->clearThumbProducer();
-    m_thumbnailQueue.removeAll(clip->getId());
+    QString id = clip->getId();
+    m_thumbnailQueue.removeAll(id);
 }
 
 void ProjectList::slotProcessNextThumbnail()
index c9c23e29c8688d7bd8a3fd76050bd82d7431f1bb..be627e3bb6de8b4045a6885d48c3ac6644762d9f 100644 (file)
@@ -977,13 +977,14 @@ int Render::setProducer(Mlt::Producer *producer, int position)
     QString currentId;
     int consumerPosition = 0;
     if (m_winid == -1) return -1;
+    if (m_mltProducer) m_mltProducer->set_speed(0);
     if (m_mltConsumer) {
+        m_mltConsumer->set("refresh", 0);
+        m_mltConsumer->purge();
         consumerPosition = m_mltConsumer->position();
         if (!m_mltConsumer->is_stopped()) {
             m_mltConsumer->stop();
-            m_mltConsumer->purge();
         }
-        m_mltConsumer->set("refresh", 0);
     }
     else {
         return -1;
@@ -991,7 +992,6 @@ int Render::setProducer(Mlt::Producer *producer, int position)
 
     if (m_mltProducer) {
         currentId = m_mltProducer->get("id");
-        m_mltProducer->set_speed(0);
         delete m_mltProducer;
         m_mltProducer = NULL;
         emit stopped();