]> git.sesse.net Git - kdenlive/commitdiff
* Fix missing proxy not re-created on project opening
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 6 Jan 2012 19:31:04 +0000 (20:31 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 6 Jan 2012 19:31:04 +0000 (20:31 +0100)
* improve proxy crash feedback
* Small change in proxy icon (use yellow color to make it more visible)

src/documentchecker.cpp
src/projectitem.cpp
src/projectlist.cpp
src/projecttree/abstractclipjob.cpp
src/projecttree/abstractclipjob.h
src/projecttree/cutclipjob.cpp
src/projecttree/proxyclipjob.cpp
src/renderer.cpp
src/renderer.h

index a89ddc13a243a05030b97b267d890fd23c5fbce1..405767386a2f42d580236615dca65ac920f55b2c 100644 (file)
@@ -325,6 +325,8 @@ bool DocumentChecker::hasErrorInClips()
         QString clipType;
         QString realPath = e.attribute("resource");
         QString id = e.attribute("id");
+        // Tell Kdenlive to recreate proxy
+        e.setAttribute("_replaceproxy", "1");
         // Replace proxy url with real clip in MLT producers
         QDomNodeList properties;
         QDomElement mltProd;
index 3e78ae06bd8c22926c78c88162ca3c426b2fbb8d..6c08423650288d032d96007c1b8befa96cfc23d6 100644 (file)
@@ -283,7 +283,7 @@ void ProjectItem::setConditionalJobStatus(CLIPJOBSTATUS status, JOBTYPE requeste
 bool ProjectItem::hasProxy() const
 {
     if (m_clip == NULL) return false;
-    if (m_clip->getProperty("proxy").isEmpty() || m_clip->getProperty("proxy") == "-" || data(0, JobProgressRole).toInt() == JOBCRASHED) return false;
+    if (m_clip->getProperty("proxy").size() < 2 || data(0, JobProgressRole).toInt() == JOBCRASHED) return false;
     return true;
 }
 
index db356c2c027fc4e20606f3acf34241eefde241aa..95c06db00bdfa9f19e952a25550eec39f141e046 100644 (file)
@@ -792,6 +792,7 @@ void ProjectList::setRenderer(Render *projectRender)
 {
     m_render = projectRender;
     m_listView->setIconSize(QSize((ProjectItem::itemDefaultHeight() - 2) * m_render->dar(), ProjectItem::itemDefaultHeight() - 2));
+    connect(m_render, SIGNAL(requestProxy(QString)), this, SLOT(slotCreateProxy(QString)));
 }
 
 void ProjectList::slotClipSelected()
@@ -1500,7 +1501,7 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged, QStr
         } else {
             item = static_cast <ProjectItem *>(*it);
             clip = item->referencedClip();
-            if (item->referencedClip()->getProducer() == NULL) {
+            if (clip->getProducer() == NULL) {
                 bool replace = false;
                 if (brokenClips.contains(item->clipId())) {
                     // if this is a proxy clip, disable proxy
@@ -1516,7 +1517,8 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged, QStr
                         xml.removeAttribute("file_hash");
                         xml.removeAttribute("proxy_out");
                     }
-                    if (!replace) replace = xml.attribute("replace") == "1";
+                    if (!replace) replace = xml.attribute("_replaceproxy") == "1";
+                    xml.removeAttribute("_replaceproxy");
                     if (replace) {
                         resetThumbsProducer(clip);
                     }
@@ -1543,7 +1545,7 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged, QStr
                     getCachedThumbnail(item);
                 }
                 if (item->data(0, DurationRole).toString().isEmpty()) {
-                    item->changeDuration(item->referencedClip()->getProducer()->get_playtime());
+                    item->changeDuration(clip->getProducer()->get_playtime());
                 }
                 if (clip->isPlaceHolder()) {
                     QPixmap pixmap = qVariantValue<QPixmap>(item->data(0, Qt::DecorationRole));
@@ -1556,6 +1558,10 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged, QStr
                     p.end();
                     item->setData(0, Qt::DecorationRole, pixmap);
                 }
+                else if (clip->getProperty("_replaceproxy") == "1") {
+                    clip->setProperty("_replaceproxy", QString());
+                    slotCreateProxy(clip->getId());
+                }
             }
             item->setData(0, UsageRole, QString::number(item->numReferences()));
         }
@@ -2590,13 +2596,7 @@ void ProjectList::slotCreateProxy(const QString id)
         slotUpdateJobStatus(item, PROXYJOB, JOBCRASHED, i18n("Failed to create proxy, empty path."));
         return;
     }
-
-    ProxyJob *job = new ProxyJob(item->clipType(), id, QStringList() << path << item->clipUrl().path() << item->referencedClip()->producerProperty("_exif_orientation") << m_doc->getDocumentProperty("proxyparams").simplified() << QString::number(m_render->frameRenderWidth()) << QString::number(m_render->renderHeight()));
-    if (job->isExclusive() && hasPendingJob(item, job->jobType)) {
-        delete job;
-        return;
-    }
-
+    
     if (QFileInfo(path).size() > 0) {
         // Proxy already created
         setJobStatus(item, PROXYJOB, JOBDONE);
@@ -2604,6 +2604,12 @@ void ProjectList::slotCreateProxy(const QString id)
         return;
     }
 
+    ProxyJob *job = new ProxyJob(item->clipType(), id, QStringList() << path << item->clipUrl().path() << item->referencedClip()->producerProperty("_exif_orientation") << m_doc->getDocumentProperty("proxyparams").simplified() << QString::number(m_render->frameRenderWidth()) << QString::number(m_render->renderHeight()));
+    if (job->isExclusive() && hasPendingJob(item, job->jobType)) {
+        delete job;
+        return;
+    }
+
     m_jobList.append(job);
     setJobStatus(item, job->jobType, JOBWAITING, 0, job->statusMessage());
     slotCheckJobProcess();
@@ -2853,7 +2859,7 @@ void ProjectList::slotProcessJobs()
                 emit addClip(destination, QString(), QString());
             }
         } else if (job->jobStatus == JOBCRASHED || job->jobStatus == JOBABORTED) {
-            emit updateJobStatus(job->clipId(), job->jobType, job->jobStatus, job->errorMessage());
+            emit updateJobStatus(job->clipId(), job->jobType, job->jobStatus, job->errorMessage(), QString(), job->logDetails());
         }
     }
     // Thread finished, cleanup & update count
@@ -2897,7 +2903,6 @@ void ProjectList::updateProxyConfig()
                 // remove proxy
                 QMap <QString, QString> newProps;
                 newProps.insert("proxy", QString());
-                newProps.insert("replace", "1");
                 // insert required duration for proxy
                 newProps.insert("proxy_out", item->referencedClip()->producerProperty("out"));
                 new EditClipCommand(this, item->clipId(), item->referencedClip()->currentProperties(newProps), newProps, true, command);
@@ -2922,7 +2927,6 @@ void ProjectList::updateProxyConfig()
                 // remove proxy
                 QMap <QString, QString> newProps;
                 newProps.insert("proxy", QString());
-                newProps.insert("replace", "1");
                 new EditClipCommand(this, item->clipId(), item->referencedClip()->properties(), newProps, true, command);
             }
         }
@@ -3098,17 +3102,13 @@ void ProjectList::processThumbOverlays(ProjectItem *item, QPixmap &pix)
 {
     if (item->hasProxy()) {
         QPainter p(&pix);
-        QColor c = QPalette().base().color();
-        c.setAlpha(200);
-        QBrush br(c);
-        p.setBrush(br);
-        p.setPen(Qt::NoPen);
-        QRect r(1, 1, 15, 15);
-        p.drawRoundedRect(r, 2, 2);
-        p.setPen(QPalette().text().color());
+        QColor c(220, 220, 10, 200);
+        QRect r(0, 0, 12, 12);
+        p.fillRect(r, c);
         QFont font = p.font();
         font.setBold(true);
         p.setFont(font);
+        p.setPen(Qt::black);
         p.drawText(r, Qt::AlignCenter, i18nc("The first letter of Proxy, used as abbreviation", "P"));
     }
 }
index 825c07241ea0a2748a5b7bf8de21bb3adfac7d6a..cc3be060d26c14a80c09adf5c505fd286f4fc6ef 100644 (file)
@@ -57,6 +57,11 @@ const QString AbstractClipJob::errorMessage() const
     return m_errorMessage;
 }
 
+const QString AbstractClipJob::logDetails() const
+{
+    return m_logDetails;
+}
+
 void AbstractClipJob::startJob()
 {
 }
index fdd049c8d082d92bcf3d90a189b56ba078c13131..29dc5762ae23769b1b7763837c67810f39fd78e1 100644 (file)
@@ -43,6 +43,7 @@ public:
     bool replaceClip;
     const QString clipId() const;
     const QString errorMessage() const;
+    const QString logDetails() const;
     void setStatus(CLIPJOBSTATUS status);
     virtual const QString destination() const;
     virtual void startJob();
@@ -54,6 +55,7 @@ public:
     
 protected:
     QString m_errorMessage;
+    QString m_logDetails;
     QProcess *m_jobProcess;
     
 signals:
index c72543ad49879177e0b4285e28e5d59da0caffbc..24e6cee0252c8026e475627dcd98cdf975c2915b 100644 (file)
@@ -105,7 +105,7 @@ void CutClipJob::processLogInfo()
 {
     if (!m_jobProcess || m_jobDuration == 0 || jobStatus == JOBABORTED) return;
     QString log = m_jobProcess->readAll();
-    if (!log.isEmpty()) m_errorMessage.append(log + '\n');
+    if (!log.isEmpty()) m_logDetails.append(log + '\n');
     int progress;
     // Parse FFmpeg output
     if (log.contains("frame=")) {
index 3bd2e53cb9663b3f71f41a2e1122e840af623a4c..88a6ac9a71a13e1c3a592909ffed6e23bb9bc904 100644 (file)
@@ -160,7 +160,7 @@ void ProxyJob::startJob()
             if (QFileInfo(m_dest).size() == 0) {
                 // File was not created
                 processLogInfo();
-                m_errorMessage.append(i18n("Failed to create file."));
+                m_errorMessage.append(i18n("Failed to create proxy clip."));
                 setStatus(JOBCRASHED);
             }
             else setStatus(JOBDONE);
@@ -180,7 +180,7 @@ void ProxyJob::processLogInfo()
 {
     if (!m_jobProcess || jobStatus == JOBABORTED) return;
     QString log = m_jobProcess->readAll();
-    if (!log.isEmpty()) m_errorMessage.append(log + '\n');
+    if (!log.isEmpty()) m_logDetails.append(log + '\n');
     else return;
     int progress;
     if (m_isFfmpegJob) {
index 16914aa3d3ce7ef16abf17b379d9117b7627cdce..aaea3fe7cd7b9e08b2574ed150ebcd4fbd691e6a 100644 (file)
@@ -644,7 +644,14 @@ void Render::processFileProperties()
         bool proxyProducer;
         if (info.xml.hasAttribute("proxy") && info.xml.attribute("proxy") != "-") {
             path = info.xml.attribute("proxy");
-            proxyProducer = true;
+            // Check for missing proxies
+            if (QFileInfo(path).size() <= 0) {
+                // proxy is missing, re-create it
+                emit requestProxy(info.clipId);
+                proxyProducer = false;
+                path = info.xml.attribute("resource");
+            }
+            else proxyProducer = true;
         }
         else {
             path = info.xml.attribute("resource");
index 809fc4fbab1385fdfa8833327070197464eac06a..800f1ea548d176bdf44134dce2f196cc01df9bfc 100644 (file)
@@ -408,6 +408,9 @@ signals:
      */
     void removeInvalidProxy(const QString &id, bool durationError);
     void refreshDocumentProducers(bool displayRatioChanged, bool fpsChanged);
+    /** @brief A proxy clip is missing, ask for creation. */
+    void requestProxy(QString);
+
 
     /** @brief A frame's image has to be shown.
      *