Commit 76b0eeac authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix bin clip thumbnails sometimes not created

parent 0be955d8
Pipeline #140880 passed with stage
in 6 minutes and 19 seconds
......@@ -501,7 +501,7 @@ QPixmap ProjectClip::thumbnail(int width, int height)
return m_thumbnail.pixmap(width, height);
}
bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer)
bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool generateThumb)
{
qDebug() << "################### ProjectClip::setproducer";
QMutexLocker locker(&m_producerMutex);
......@@ -542,6 +542,10 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer)
getFileHash();
// set parent again (some info need to be stored in producer)
updateParent(parentItem().lock());
if (generateThumb && m_clipType != ClipType::Audio) {
// Generate video thumb
ClipLoadTask::start({ObjectType::BinClip,m_binId.toInt()}, QDomElement(), true, -1, -1, this);
}
if (KdenliveSettings::audiothumbnails() && (m_clipType == ClipType::AV || m_clipType == ClipType::Audio || m_clipType == ClipType::Playlist || m_clipType == ClipType::Unknown)) {
AudioLevelsTask::start({ObjectType::BinClip, m_binId.toInt()}, this, false);
}
......
......@@ -289,7 +289,7 @@ public slots:
* @param replaceProducer If true, we replace existing producer with this one
* @returns true if producer was changed
* . */
bool setProducer(std::shared_ptr<Mlt::Producer> producer);
bool setProducer(std::shared_ptr<Mlt::Producer> producer, bool generateThumb = false);
void importJsonMarkers(const QString &json);
/** @brief Refresh zones of insertion in timeline. */
......
......@@ -225,7 +225,7 @@ void ClipLoadTask::generateThumbnail(std::shared_ptr<ProjectClip>binClip, std::s
// Fetch thumbnail
qDebug()<<"===== \nREADY FOR THUMB"<<binClip->clipType()<<"\n\n=========";
int frameNumber = m_in > -1 ? m_in : qMax(0, binClip->getProducerIntProperty(QStringLiteral("kdenlive:thumbnailFrame")));
if (binClip->clipType() != ClipType::Audio && producer->get_int("video_index") > -1) {
if (producer->get_int("video_index") > -1) {
if (ThumbnailCache::get()->hasThumbnail(QString::number(m_owner.second), frameNumber, false)) {
// Thumbnail found in cache
QImage result = ThumbnailCache::get()->getThumbnail(QString::number(m_owner.second), frameNumber);
......@@ -659,13 +659,12 @@ void ClipLoadTask::run()
if (!m_isCanceled) {
auto binClip = pCore->projectItemModel()->getClipByBinID(QString::number(m_owner.second));
if (binClip) {
QMetaObject::invokeMethod(binClip.get(), "setProducer", Qt::QueuedConnection, Q_ARG(std::shared_ptr<Mlt::Producer>,producer));
QMetaObject::invokeMethod(binClip.get(), "setProducer", Qt::QueuedConnection, Q_ARG(std::shared_ptr<Mlt::Producer>,producer), Q_ARG(bool,true));
if (checkProfile && !isVariableFrameRate && seekable) {
pCore->bin()->shouldCheckProfile = false;
QMetaObject::invokeMethod(pCore->bin(), "slotCheckProfile", Qt::QueuedConnection, Q_ARG(QString, QString::number(m_owner.second)));
}
}
generateThumbnail(binClip, producer);
emit taskDone();
} else {
// Might be aborted by profile switch
......
......@@ -37,7 +37,7 @@ void ProxyTask::start(const ObjectId &owner, QObject* object, bool force)
task = nullptr;
}
if (task) {
// Otherwise, start a new audio levels generation thread.
// Otherwise, start a new proxy generation thread.
task->m_isForce = force;
pCore->taskManager.startTask(owner.second, task);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment