]> git.sesse.net Git - kdenlive/commitdiff
Fix white thumbnails in timeline when audio only copy of clip was in timeline
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 28 Jun 2011 00:04:05 +0000 (00:04 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 28 Jun 2011 00:04:05 +0000 (00:04 +0000)
svn path=/trunk/kdenlive/; revision=5738

src/docclipbase.cpp
src/kthumb.cpp
src/projectlist.cpp

index cb947a9b9caf1a4d7720db73901b67fafe13da5c..677eee7e692d9a2c030ec55ccd6a23667c413f21 100644 (file)
@@ -458,13 +458,22 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset, bool readProp
         producer->set("pad", "10");
         delete[] tmp;
     }
-    if (m_thumbProd && (reset || !m_thumbProd->hasProducer())) m_thumbProd->setProducer(producer);
+    QString id = producer->get("id");
+    if (m_thumbProd) {
+        if (reset) m_thumbProd->setProducer(NULL);
+        if (!m_thumbProd->hasProducer()) {
+            if (m_clipType != AUDIO) {
+                if (!id.endsWith("_audio"))
+                    m_thumbProd->setProducer(producer);
+            }
+            else m_thumbProd->setProducer(producer);
+        }
+    }
     if (reset) {
         // Clear all previous producers
         kDebug() << "/+++++++++++++++   DELETE ALL PRODS " << producer->get("id");
         deleteProducers(false);
     }
-    QString id = producer->get("id");
     bool updated = false;
     if (id.contains('_')) {
         // this is a subtrack producer, insert it at correct place
@@ -928,7 +937,7 @@ QString DocClipBase::getClipHash() const
     else if (m_clipType == TEXT) hash = QCryptographicHash::hash(QString("title" + getId() + m_properties.value("xmldata")).toUtf8().data(), QCryptographicHash::Md5).toHex();
     else {
         if (m_properties.contains("file_hash")) hash = m_properties.value("file_hash");
-        else hash = getHash(fileURL().path());
+        if (hash.isEmpty()) hash = getHash(fileURL().path());
         
     }
     return hash;
index bde533a5f47d8cec363f03a72ce2fdbd58dc9604..3208ea4d404b8125902e931f3f3476d374798e00 100644 (file)
@@ -72,12 +72,12 @@ 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();
+    if (producer) m_dar = producer->profile()->dar();
 }
 
 void KThumb::clearProducer()
 {
-    m_producer = NULL;
+    setProducer(NULL);
 }
 
 bool KThumb::hasProducer() const
@@ -376,8 +376,8 @@ void KThumb::getAudioThumbs(int channel, double frame, double frameLength, int a
 void KThumb::slotCreateAudioThumbs()
 {
     Mlt::Profile prof((char*) KdenliveSettings::current_profile().toUtf8().data());
-    Mlt::Producer m_producer(prof, m_url.path().toUtf8().data());
-    if (!m_producer.is_valid()) {
+    Mlt::Producer producer(prof, m_url.path().toUtf8().data());
+    if (!producer.is_valid()) {
         kDebug() << "++++++++  INVALID CLIP: " << m_url.path();
         return;
     }
@@ -391,23 +391,23 @@ void KThumb::slotCreateAudioThumbs()
     if (KdenliveSettings::normaliseaudiothumbs()) {
         Mlt::Filter m_convert(prof, "volume");
         m_convert.set("gain", "normalise");
-        m_producer.attach(m_convert);
+        producer.attach(m_convert);
     }
 
     int last_val = 0;
     int val = 0;
     //kDebug() << "for " << m_frame << " " << m_frameLength << " " << m_producer.is_valid();
-    for (int z = (int) m_frame; z < (int)(m_frame + m_frameLength) && m_producer.is_valid(); z++) {
+    for (int z = (int) m_frame; z < (int)(m_frame + m_frameLength) && producer.is_valid(); z++) {
         if (m_stopAudioThumbs) break;
         val = (int)((z - m_frame) / (m_frame + m_frameLength) * 100.0);
         if (last_val != val && val > 1) {
             m_clipManager->setThumbsProgress(i18n("Creating thumbnail for %1", m_url.fileName()), val);
             last_val = val;
         }
-        m_producer.seek(z);
-        Mlt::Frame *mlt_frame = m_producer.get_frame();
+        producer.seek(z);
+        Mlt::Frame *mlt_frame = producer.get_frame();
         if (mlt_frame && mlt_frame->is_valid()) {
-            double m_framesPerSecond = mlt_producer_get_fps(m_producer.get_producer());
+            double m_framesPerSecond = mlt_producer_get_fps(producer.get_producer());
             int m_samples = mlt_sample_calculator(m_framesPerSecond, m_frequency, mlt_frame_get_position(mlt_frame->get_frame()));
             mlt_audio_format m_audioFormat = mlt_audio_pcm;
             qint16* m_pcm = static_cast<qint16*>(mlt_frame->get_audio(m_audioFormat, m_frequency, m_channels, m_samples));
index 8bb2d2bf658b469e221574cd84a0f63ca9cc22dd..5d74c7bdd3e313daab2b8286983f89e6a05335af 100644 (file)
@@ -1352,6 +1352,7 @@ void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
 {
     ProjectItem *item = getItemById(id);
     m_processingClips.removeAll(id);
+    m_thumbnailQueue.removeAll(id);
     if (!m_queueRunner.isRunning() && m_processingClips.isEmpty()) m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);
     if (item) {
         const QString path = item->referencedClip()->fileURL().path();
@@ -1385,6 +1386,7 @@ void ProjectList::slotRemoveInvalidProxy(const QString &id, bool durationError)
         }
     }
     m_processingClips.removeAll(id);
+    m_thumbnailQueue.removeAll(id);
     if (!m_queueRunner.isRunning() && m_processingClips.isEmpty()) m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);
 }
 
@@ -1726,7 +1728,8 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
     }
     if (item && m_listView->isEnabled() && replace) {
             // update clip in clip monitor
-            emit clipSelected(item->referencedClip());
+            if (item->isSelected() && m_listView->selectedItems().count() == 1)
+                emit clipSelected(item->referencedClip());
             //TODO: Make sure the line below has no side effect
             toReload = clipId;
         }