]> git.sesse.net Git - kdenlive/commitdiff
Fix crash when enabling a proxy clip
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 23 Oct 2011 22:07:09 +0000 (22:07 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 23 Oct 2011 22:07:09 +0000 (22:07 +0000)
svn path=/trunk/kdenlive/; revision=5982

src/mainwindow.cpp
src/mainwindow.h
src/projectlist.cpp
src/projectlist.h
src/renderer.cpp
src/renderer.h

index 48559efb6307a4ada2c190e073b231329932fecf..270bdb86afb50a14591d6a87a1b8057fb8a9442e 100644 (file)
@@ -840,6 +840,7 @@ void MainWindow::slotAddEffect(const QDomElement effect)
 void MainWindow::slotUpdateClip(const QString &id)
 {
     if (!m_activeDocument) return;
+    kDebug()<<"//\n\n RECIEVED UPDATED PRODUCER FOR: "<<id<<"\n\n--------------------";
     DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
     if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
     if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
@@ -859,7 +860,7 @@ void MainWindow::slotConnectMonitors()
     connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
     connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
     connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
-    connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool, bool)), this, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool, bool)));
+    connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)));
 
     connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
     
@@ -4386,12 +4387,6 @@ void MainWindow::slotOpenBackupDialog(const KUrl url)
     delete dia;
 }
 
-void MainWindow::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace, bool refreshThumbnail)
-{
-    m_projectList->slotReplyGetFileProperties(clipId, producer, properties, metadata, replace, refreshThumbnail);
-}
-
-
 void MainWindow::slotElapsedTime()
 {
     kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
index bcd9b5a0fb87ff1e0dc14d90d85e63140936c878..075132f2d3623dbe4df8f6ffce4d5fa0545c5f41 100644 (file)
@@ -544,8 +544,6 @@ private slots:
     void slotInsertNotesTimecode();
     /** @brief Open the project's backupdialog. */
     void slotOpenBackupDialog(const KUrl url = KUrl());
-    /** @brief Make sure to update clip monitor before deleting a clip's producer. */
-    void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace, bool refreshThumbnail);
     /** @brief Disable proxies for this project. */
     void slotDisableProxies();
 
index 72a7acbb02efca47c40fc75d49a5c10b130e9602..b45a6dac28d5e9f11cf3f2f770991cbbec751da5 100644 (file)
@@ -129,10 +129,6 @@ ProjectList::ProjectList(QWidget *parent) :
     QHBoxLayout *box = new QHBoxLayout;
     KTreeWidgetSearchLine *searchView = new KTreeWidgetSearchLine;
 
-    m_refreshMonitorTimer.setSingleShot(true);
-    m_refreshMonitorTimer.setInterval(100);
-    connect(&m_refreshMonitorTimer, SIGNAL(timeout()), this, SLOT(slotRefreshMonitor()));
-
     box->addWidget(searchView);
     //int s = style()->pixelMetric(QStyle::PM_SmallIconSize);
     //m_toolbar->setIconSize(QSize(s, s));
@@ -625,7 +621,6 @@ void ProjectList::setRenderer(Render *projectRender)
 
 void ProjectList::slotClipSelected()
 {
-    m_refreshMonitorTimer.stop();
     QTreeWidgetItem *item = m_listView->currentItem();
     ProjectItem *clip = NULL;
     if (item) {
@@ -1143,6 +1138,12 @@ void ProjectList::slotGotProxy(ProjectItem *item)
 {
     if (item == NULL || !m_refreshed) return;
     DocClipBase *clip = item->referencedClip();
+    if (!clip || !clip->isClean() || m_render->isProcessing(item->clipId())) {
+        // Clip is being reprocessed, abort
+        kDebug()<<"//// TRYING TO PROXY: "<<item->clipId()<<", but it is busy";
+        return;
+    }
+    
     // Proxy clip successfully created
     QDomElement e = clip->toXML().cloneNode().toElement();
 
@@ -1720,18 +1721,8 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
     }
 }
 
-void ProjectList::slotRefreshMonitor()
-{
-    if (m_listView->selectedItems().count() == 1 && m_render && m_render->processingItems() == 0) {
-        if (m_listView->currentItem() && m_listView->currentItem()->type() != PROJECTFOLDERTYPE) {
-            ProjectItem *item = static_cast <ProjectItem*>(m_listView->currentItem());
-            DocClipBase *clip = item->referencedClip();
-            if (clip && clip->isClean() && !m_render->isProcessing(item->clipId())) emit clipSelected(clip);
-        }
-    }
-}
 
-void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace, bool refreshThumbnail)
+void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace)
 {
     QString toReload;
     ProjectItem *item = getItemById(clipId);
@@ -1753,7 +1744,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
         item->setProperties(properties, metadata);
         clip->setProducer(producer, replace);
         clip->askForAudioThumbs();
-        if (refreshThumbnail) getCachedThumbnail(item);
+
         // Proxy stuff
         QString size = properties.value("frame_size");
         if (!useProxy() && clip->getProperty("proxy").isEmpty()) setProxyStatus(item, NOPROXY);
@@ -1781,7 +1772,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             }
         }
 
-        if (!replace && item->data(0, Qt::DecorationRole).isNull() && !refreshThumbnail) {
+        if (!replace && item->data(0, Qt::DecorationRole).isNull()) {
             requestClipThumbnail(clipId);
         }
         if (!toReload.isEmpty())
@@ -1810,9 +1801,6 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
     }
     if (replace && item) {
         toReload = clipId;
-        // update clip in clip monitor
-        /*if (queue == 0 && item->isSelected() && m_listView->selectedItems().count() == 1)
-            m_refreshMonitorTimer.start();*/
     }
     if (!item) {
         // no item for producer, delete it
@@ -2602,7 +2590,11 @@ void ProjectList::slotProxyCurrentItem(bool doProxy)
             if ((t == VIDEO || t == AV || t == UNKNOWN || t == IMAGE || t == PLAYLIST) && item->referencedClip()) {
                 if ((doProxy && item->hasProxy()) || (!doProxy && !item->hasProxy())) continue;
                 DocClipBase *clip = item->referencedClip();
-                if (!clip->isClean() || m_render->isProcessing(item->clipId())) continue;
+                if (!clip || !clip->isClean() || m_render->isProcessing(item->clipId())) {
+                    kDebug()<<"//// TRYING TO PROXY: "<<item->clipId()<<", but it is busy";
+                    continue;
+                }
+                
                 resetThumbsProducer(clip);
                 oldProps = clip->properties();
                 if (doProxy) {
index fbebd9f69f45578d956342b28a982af595ca9d63..7aa86310b6154178e31601baa58944559783d495 100644 (file)
@@ -242,7 +242,7 @@ public slots:
     void updateAllClips(bool displayRatioChanged, bool fpsChanged);
     void slotReplyGetImage(const QString &clipId, const QImage &img);
     void slotReplyGetImage(const QString &clipId, const QString &name, int width, int height);
-    void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace, bool refreshThumbnail);
+    void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace);
     void slotAddClip(DocClipBase *clip, bool getProperties);
     void slotDeleteClip(const QString &clipId);
     void slotUpdateClip(const QString &id);
@@ -309,7 +309,6 @@ private:
     QList <PROXYINFO> m_proxyList;
     QFutureSynchronizer<void> m_proxyThreads;
     InvalidDialog *m_invalidClipDialog;
-    QTimer m_refreshMonitorTimer;
     
     void requestClipThumbnail(const QString id);
 
@@ -382,9 +381,7 @@ private slots:
     /** @brief Stop creation of this clip's proxy. */
     void slotAbortProxy(const QString id, const QString path);
     /** @brief Start creation of proxy clip. */
-    void slotGenerateProxy();//const QString destPath, const QString sourcePath, int clipType, int exif);
-    /** @brief Timer triggering a refresh of the clip monitor. */
-    void slotRefreshMonitor();
+    void slotGenerateProxy();
 
 signals:
     void clipSelected(DocClipBase *, QPoint zone = QPoint());
index 576ba1feba7b28c86227d5cbcbd3f403be724d86..88666e0fab08c0f80456d676900af20ec5416a00 100644 (file)
@@ -748,20 +748,30 @@ void Render::processFileProperties()
 
         if (info.xml.hasAttribute("templatetext"))
             producer->set("templatetext", info.xml.attribute("templatetext").toUtf8().constData());
+
+        int imageWidth = (int)((double) info.imageHeight * m_mltProfile->width() / m_mltProfile->height() + 0.5);
+        int fullWidth = (int)((double) info.imageHeight * m_mltProfile->dar() + 0.5);
+        int frameNumber = info.xml.attribute("thumbnail", "-1").toInt();
         
         if ((!info.replaceProducer && info.xml.hasAttribute("file_hash")) || proxyProducer) {
             // Clip  already has all properties
-            emit replyGetFileProperties(info.clipId, producer, stringMap(), stringMap(), info.replaceProducer, true);
+            if (proxyProducer) {
+                // Recreate clip thumb
+                if (frameNumber > 0) producer->seek(frameNumber);
+                Mlt::Frame *frame = producer->get_frame();
+                if (frame && frame->is_valid()) {
+                    QImage img = KThumb::getFrame(frame, imageWidth, fullWidth, info.imageHeight);
+                    delete frame;
+                    emit replyGetImage(info.clipId, img);
+                }
+            }
+            emit replyGetFileProperties(info.clipId, producer, stringMap(), stringMap(), info.replaceProducer);
             m_processingClipId.clear();
             continue;
         }
 
-        int imageWidth = (int)((double) info.imageHeight * m_mltProfile->width() / m_mltProfile->height() + 0.5);
-        int fullWidth = (int)((double) info.imageHeight * m_mltProfile->dar() + 0.5);
         stringMap filePropertyMap;
         stringMap metadataPropertyMap;
-
-        int frameNumber = info.xml.attribute("thumbnail", "-1").toInt();
         if (frameNumber > 0) producer->seek(frameNumber);
         
         duration = duration > 0 ? duration : producer->get_playtime();
index a8de89ea711acb77f1565e0e81867f81de9fea76..4fb5b1b5fa6b0c6aa050283378093b9c84158efa 100644 (file)
@@ -372,7 +372,7 @@ private slots:
 signals:
 
     /** @brief The renderer received a reply to a getFileProperties request. */
-    void replyGetFileProperties(const QString &clipId, Mlt::Producer*, const stringMap &, const stringMap &, bool replaceProducer, bool refreshThumbnail = false);
+    void replyGetFileProperties(const QString &clipId, Mlt::Producer*, const stringMap &, const stringMap &, bool replaceProducer);
 
     /** @brief The renderer received a reply to a getImage request. */
     void replyGetImage(const QString &, const QString &, int, int);