]> git.sesse.net Git - kdenlive/commitdiff
Finally fixed the proxy crash,
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 28 Jun 2011 18:40:56 +0000 (18:40 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 28 Jun 2011 18:40:56 +0000 (18:40 +0000)
and a shortcut can now be assigned to proxy action

svn path=/trunk/kdenlive/; revision=5743

src/clipitem.cpp
src/docclipbase.cpp
src/docclipbase.h
src/kdenliveui.rc
src/kthumb.cpp
src/mainwindow.cpp
src/projectlist.cpp
src/renderer.cpp
src/renderer.h

index d59a562d7015f8d4eeb2a177ea0519255379edce..4bf64cb155bd449d2aba629ac8a765bc050f52e6 100644 (file)
@@ -511,6 +511,7 @@ void ClipItem::resetThumbs(bool clearExistingThumbs)
         m_endPix = QPixmap();
         m_audioThumbCachePic.clear();
     }
+    kDebug()<<"...........  RESET THMBS";
     slotFetchThumbs();
 }
 
index cb63298a47439f406021c4d10dcb0b4b80312c43..fcf99fd28892c005247c2da589f67ffdcd283163 100644 (file)
@@ -450,7 +450,7 @@ void DocClipBase::setValid()
 void DocClipBase::setProducer(Mlt::Producer *producer, bool reset, bool readPropertiesFromProducer)
 {
     if (producer == NULL || !producer->is_valid()) return;
-    if (reset) m_producerMutex.lock();
+    if (reset) QMutexLocker locker(&m_producerMutex);
     if (m_placeHolder) {
         char *tmp = qstrdup(i18n("Missing clip").toUtf8().constData());
         producer->set("markup", tmp);
@@ -489,14 +489,12 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset, bool readProp
                 m_audioTrackProducers[pos] = producer;
                 updated = true;
             }
-            if (reset) m_producerMutex.unlock();
             return;
         } else if (id.endsWith("video")) {
             if (m_videoOnlyProducer == NULL) {
                 m_videoOnlyProducer = producer;
                 updated = true;
             }
-            if (reset) m_producerMutex.unlock();
             return;
         }
         int pos = id.toInt();
@@ -521,7 +519,6 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset, bool readProp
     }
     if (updated && readPropertiesFromProducer && (m_clipType != COLOR && m_clipType != IMAGE && m_clipType != TEXT))
         setDuration(GenTime(producer->get_length(), KdenliveSettings::project_fps()));
-    if (reset) m_producerMutex.unlock();
 }
 
 static double getPixelAspect(QMap<QString, QString>& props) {
@@ -537,7 +534,7 @@ static double getPixelAspect(QMap<QString, QString>& props) {
 
 Mlt::Producer *DocClipBase::audioProducer(int track)
 {
-    m_producerMutex.lock();
+    QMutexLocker locker(&m_producerMutex);
     if (m_audioTrackProducers.count() <= track) {
         while (m_audioTrackProducers.count() - 1 < track) {
             m_audioTrackProducers.append(NULL);
@@ -550,18 +547,17 @@ Mlt::Producer *DocClipBase::audioProducer(int track)
         Mlt::Producer *base;
         if (i >= m_audioTrackProducers.count()) {
             // Could not find a valid producer for that clip
-            m_producerMutex.unlock();
+            locker.unlock();
             base = producer();
             if (base == NULL) {
                 return NULL;
             }
-            m_producerMutex.lock();
+            locker.relock();
         }
         else base = m_audioTrackProducers.at(i);
         m_audioTrackProducers[track] = cloneProducer(base);
         adjustProducerProperties(m_audioTrackProducers.at(track), QString(getId() + '_' + QString::number(track) + "_audio"), false, true);
     }
-    m_producerMutex.unlock();
     return m_audioTrackProducers.at(track);
 }
 
@@ -591,7 +587,7 @@ void DocClipBase::adjustProducerProperties(Mlt::Producer *prod, const QString &i
 
 Mlt::Producer *DocClipBase::videoProducer()
 {
-    m_producerMutex.lock();
+    QMutexLocker locker(&m_producerMutex);
     if (m_videoOnlyProducer == NULL) {
         int i;
         for (i = 0; i < m_baseTrackProducers.count(); i++)
@@ -600,25 +596,21 @@ Mlt::Producer *DocClipBase::videoProducer()
         m_videoOnlyProducer = cloneProducer(m_baseTrackProducers.at(i));
         adjustProducerProperties(m_videoOnlyProducer, QString(getId() + "_video"), true, false);
     }
-    m_producerMutex.unlock();
     return m_videoOnlyProducer;
 }
 
 Mlt::Producer *DocClipBase::producer(int track)
 {
-    m_producerMutex.lock();
+    QMutexLocker locker(&m_producerMutex);
     if (track == -1 || (m_clipType != AUDIO && m_clipType != AV && m_clipType != PLAYLIST)) {
         if (m_baseTrackProducers.count() == 0) {
-            m_producerMutex.unlock();
             return NULL;
         }
         for (int i = 0; i < m_baseTrackProducers.count(); i++) {
             if (m_baseTrackProducers.at(i) != NULL) {
-                m_producerMutex.unlock();
                 return m_baseTrackProducers.at(i);
             }
         }
-        m_producerMutex.unlock();
         return NULL;
     }
     if (track >= m_baseTrackProducers.count()) {
@@ -633,13 +625,11 @@ Mlt::Producer *DocClipBase::producer(int track)
 
         if (i >= m_baseTrackProducers.count()) {
             // Could not find a valid producer for that clip, check in 
-            m_producerMutex.unlock();
             return NULL;
         }
         m_baseTrackProducers[track] = cloneProducer(m_baseTrackProducers.at(i));
         adjustProducerProperties(m_baseTrackProducers.at(track), QString(getId() + '_' + QString::number(track)), false, false);
     }
-    m_producerMutex.unlock();
     return m_baseTrackProducers.at(track);
 }
 
@@ -1164,22 +1154,11 @@ void DocClipBase::slotExtractImage(int frame, int frame2)
     m_thumbProd->extractImage(frame, frame2);
 }
 
-void DocClipBase::slotBlock()
-{
-    m_producerMutex.lock();
-}
-
-void DocClipBase::slotRelease()
-{
-    m_producerMutex.unlock();
-}
-
 QPixmap DocClipBase::extractImage(int frame, int width, int height)
 {
     if (m_thumbProd == NULL) return QPixmap(width, height);
-    m_producerMutex.lock();
+    QMutexLocker locker(&m_producerMutex);
     QPixmap p = m_thumbProd->extractImage(frame, width, height);
-    m_producerMutex.unlock();
     return p;
 }
 
index c66fcfde9174523db354c312cb729c467d7137ae..a19d226215512e79681f8147b9ca411ef8aa5061 100644 (file)
@@ -274,10 +274,6 @@ public slots:
     QMap <QString, QString> properties() const;
     QMap <QString, QString> metadata() const;
     void slotExtractImage(int frame, int frame2);
-    /** @brief Lock mutex to prevent changing producers while operation. */
-    void slotBlock();
-    /** @brief Release mutex preventing a change in producers. */
-    void slotRelease();
 
 signals:
     void gotAudioData();
index fb54b57869f78a71081ec6e2e96c8e866ed96bbd..a17892b7f6c9637dde66c0569492e907b83dff20 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui name="kdenlive" version="63">
+<gui name="kdenlive" version="64">
   <ToolBar name="extraToolBar" >
     <text>Extra Toolbar</text>
        <Action name="project_render" />
@@ -38,6 +38,7 @@
       <Action name="stopmotion" />
       <Separator />
       <Action name="reload_clip" />
+      <Action name="proxy_clip" />
       <Menu name="clip_in_timeline"><text>Clip in Timeline</text>
       </Menu>
       <Action name="clip_properties" />
index 29ac0f0670071f6bc18703a84b380b8db63c5691..09f8802a6ff0f0a07911b14957ca11b52fe89eee 100644 (file)
@@ -97,8 +97,8 @@ void KThumb::updateThumbUrl(const QString &hash)
 void KThumb::updateClipUrl(KUrl url, const QString &hash)
 {
     m_url = url;
-    if (m_producer)
-        m_producer->set("resource", url.path().toUtf8().constData());
+    //if (m_producer)
+        //m_producer->set("resource", url.path().toUtf8().constData());
     m_thumbFile = m_clipManager->projectFolder() + "/thumbs/" + hash + ".thumb";
 }
 
index 9ae246b65759157181e79435e1e128ce5c760eaf..ea51b42ccf3602f85d163707e02120ff8aaf011a 100644 (file)
@@ -1590,6 +1590,13 @@ void MainWindow::setupActions()
     connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
     reloadClip->setEnabled(false);
 
+    QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
+    collection.addAction("proxy_clip", proxyClip);
+    proxyClip->setData("proxy_clip");
+    proxyClip->setCheckable(true);
+    proxyClip->setChecked(false);
+    connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
+    
     QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
     collection.addAction("stopmotion", stopMotion);
     connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
@@ -1603,6 +1610,7 @@ void MainWindow::setupActions()
     addClips->addAction(addFolderButton);
 
     addClips->addAction(reloadClip);
+    addClips->addAction(proxyClip);
     addClips->addAction(clipProperties);
     addClips->addAction(openClip);
     addClips->addAction(deleteClip);
index 5d74c7bdd3e313daab2b8286983f89e6a05335af..1b71947680b70752851cf66d8df575894c2746a7 100644 (file)
@@ -114,10 +114,6 @@ ProjectList::ProjectList(QWidget *parent) :
     setLayout(layout);
     searchView->setTreeWidget(m_listView);
 
-    m_proxyAction = new QAction(i18n("Proxy clip"), this);
-    m_proxyAction->setCheckable(true);
-    m_proxyAction->setChecked(false);
-    connect(m_proxyAction, SIGNAL(toggled(bool)), this, SLOT(slotProxyCurrentItem(bool)));
     connect(this, SIGNAL(processNextThumbnail()), this, SLOT(slotProcessNextThumbnail()));
     connect(m_listView, SIGNAL(projectModified()), this, SIGNAL(projectModified()));
     connect(m_listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
@@ -176,6 +172,10 @@ void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction)
             m_reloadAction = actions.at(i);
             actions.removeAt(i);
             i--;
+        } else if (actions.at(i)->data().toString() == "proxy_clip") {
+            m_proxyAction = actions.at(i);
+            actions.removeAt(i);
+            i--;
         }
     }
 
@@ -1132,7 +1132,7 @@ void ProjectList::slotProcessNextClipInQueue()
 
     QMap<QString, QDomElement>::const_iterator j = m_infoQueue.constBegin();
     if (j != m_infoQueue.constEnd()) {
-        QDomElement dom = j.value();
+        QDomElement dom = j.value().cloneNode().toElement();
         const QString id = j.key();
         m_infoQueue.remove(id);
         m_processingClips.append(id);
@@ -1661,7 +1661,6 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
     }
     m_processingClips.removeAll(clipId);
     if (m_infoQueue.isEmpty() && m_processingClips.isEmpty()) m_listView->setEnabled(true);
-
     if (item && producer) {
         //m_listView->blockSignals(true);
         monitorItemEditing(false);
@@ -2383,7 +2382,7 @@ void ProjectList::updateProxyConfig()
                 if (clip->getProperty("frame_size").section('x', 0, 0).toInt() > m_doc->getDocumentProperty("proxyminsize").toInt()) {
                     if (clip->getProperty("proxy").isEmpty()) {
                         // We need to insert empty proxy in old properties so that undo will work
-                        QMap <QString, QString> oldProps = clip->properties();
+                        QMap <QString, QString> oldProps;// = clip->properties();
                         oldProps.insert("proxy", QString());
                         QMap <QString, QString> newProps;
                         newProps.insert("proxy", proxydir + item->referencedClip()->getClipHash() + "." + m_doc->getDocumentProperty("proxyextension"));
index 8e750e5ddc66ba5fe3adfaa2e700ba5ab11f6e24..77ce5be3b1fc54508c3477fdd4cab33d2afc3d0e 100644 (file)
@@ -571,7 +571,7 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
         proxyProducer = false;
     }
 
-    KUrl url = KUrl(path);
+    KUrl url(path);
     Mlt::Producer *producer = NULL;
     CLIPTYPE type = (CLIPTYPE)xml.attribute("type").toInt();
     //kDebug() << "PROFILE WIDT: "<< xml.attribute("mlt_service") << ": "<< m_mltProfile->width() << "\n...................\n\n";
@@ -595,12 +595,12 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
         play.appendChild(doc.importNode(xml, true));
         producer = new Mlt::Producer(*m_mltProfile, "xml-string", doc.toString().toUtf8().constData());
     } else {
-        producer = new Mlt::Producer(*m_mltProfile, url.path().toUtf8().constData());
+        producer = new Mlt::Producer(*m_mltProfile, path.toUtf8().constData());
     }
 
 
     if (producer == NULL || producer->is_blank() || !producer->is_valid()) {
-        kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: ";
+        kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: "<<path;
         if (proxyProducer) {
             // Proxy file is corrupted
             emit removeInvalidProxy(clipId, false);
@@ -697,6 +697,9 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
     if ((!replaceProducer && xml.hasAttribute("file_hash")) || xml.hasAttribute("proxy")) {
         // Clip  already has all properties
         if (replaceProducer) emit blockClipMonitor(clipId);
+        // Querying a frame is required by MLT, otherwise the producer is not correctly initialised
+        Mlt::Frame *frame = producer->get_frame();
+        delete frame;
         emit replyGetFileProperties(clipId, producer, QMap < QString, QString >(), QMap < QString, QString >(), replaceProducer, selectClip);
         return;
     }
@@ -933,15 +936,17 @@ void Render::initSceneList()
 
 int Render::setProducer(Mlt::Producer *producer, int position)
 {
+    QMutexLocker locker(&m_mutex);
     if (m_winid == -1) return -1;
-
     if (m_mltConsumer) {
         if (!m_mltConsumer->is_stopped()) {
             m_mltConsumer->stop();
         }
         m_mltConsumer->set("refresh", 0);
     }
-    else return -1;
+    else {
+        return -1;
+    }
 
     m_isBlocked = true;
     if (m_mltProducer) {
@@ -951,7 +956,7 @@ int Render::setProducer(Mlt::Producer *producer, int position)
         emit stopped();
     }
     blockSignals(true);
-    if (producer) {
+    if (producer && producer->is_valid()) {
         m_mltProducer = new Mlt::Producer(producer->get_producer());
     } else m_mltProducer = m_blackClip->cut(0, 50);
 
index 93e69f35c3f5bf478cf49b474b19ad4adbd40b56..39690902bb8cd32b2d151ce1d7a166fcc8f78d5f 100644 (file)
@@ -41,7 +41,7 @@
 #include <qmap.h>
 #include <QList>
 #include <QEvent>
-
+#include <QMutex>
 
 class QTimer;
 class QPixmap;
@@ -301,6 +301,7 @@ private:
     QString m_activeProfile;
 
     QTimer *m_osdTimer;
+    QMutex m_mutex;
 
     /** @brief A human-readable description of this renderer. */
     int m_winid;
@@ -362,7 +363,7 @@ signals:
     void removeInvalidProxy(const QString &id, bool durationError);
     void refreshDocumentProducers(bool displayRatioChanged, bool fpsChanged);
     
-    /** @brief If we will delete the producer, make sure to oause the monitor */
+    /** @brief If we will delete the producer, make sure to pause the monitor */
     void blockClipMonitor(const QString);
 
     /** @brief A frame's image has to be shown.