From 24bf4e16f446c1c4b2e5a6939155e0cf00d2c792 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 28 Jun 2011 00:04:05 +0000 Subject: [PATCH] Fix white thumbnails in timeline when audio only copy of clip was in timeline svn path=/trunk/kdenlive/; revision=5738 --- src/docclipbase.cpp | 15 ++++++++++++--- src/kthumb.cpp | 18 +++++++++--------- src/projectlist.cpp | 5 ++++- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index cb947a9b..677eee7e 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -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; diff --git a/src/kthumb.cpp b/src/kthumb.cpp index bde533a5..3208ea4d 100644 --- a/src/kthumb.cpp +++ b/src/kthumb.cpp @@ -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(mlt_frame->get_audio(m_audioFormat, m_frequency, m_channels, m_samples)); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 8bb2d2bf..5d74c7bd 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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; } -- 2.39.2