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

Fix clip task sometimes not performed because of older pending task

parent 34a5cbf8
Pipeline #150558 passed with stage
in 6 minutes and 57 seconds
......@@ -58,7 +58,7 @@ void AbstractProjectItem::setRefCount(uint count, uint audioCount)
m_AudioUsage = audioCount;
if (auto ptr = m_model.lock())
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<AbstractProjectItem>(shared_from_this()),
AbstractProjectItem::UsageCount);
{AbstractProjectItem::UsageCount});
}
uint AbstractProjectItem::refCount() const
......@@ -74,7 +74,7 @@ void AbstractProjectItem::addRef(bool isAudio)
}
if (auto ptr = m_model.lock())
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<AbstractProjectItem>(shared_from_this()),
AbstractProjectItem::UsageCount);
{AbstractProjectItem::UsageCount});
}
void AbstractProjectItem::removeRef(bool isAudio)
......@@ -85,7 +85,7 @@ void AbstractProjectItem::removeRef(bool isAudio)
}
if (auto ptr = m_model.lock())
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<AbstractProjectItem>(shared_from_this()),
AbstractProjectItem::UsageCount);
{AbstractProjectItem::UsageCount});
}
const QString &AbstractProjectItem::clipId() const
......
......@@ -185,7 +185,7 @@ void ProjectClip::connectEffectStack()
connect(m_effectStack.get(), &EffectStackModel::dataChanged, this, [&]() {
if (auto ptr = m_model.lock()) {
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::IconOverlay);
{AbstractProjectItem::IconOverlay});
}
});
}
......@@ -408,6 +408,7 @@ void ProjectClip::reloadProducer(bool refreshOnly, bool isProxy, bool forceAudio
if (!xml.isNull()) {
bool hashChanged = false;
m_thumbsProducer.reset();
m_clipStatus = FileStatus::StatusWaiting;
ClipType::ProducerType type = clipType();
if (type != ClipType::Color && type != ClipType::Image && type != ClipType::SlideShow) {
xml.removeAttribute("out");
......@@ -480,7 +481,7 @@ void ProjectClip::setThumbnail(const QImage &img, int in, int out, bool inCache)
m_thumbnail = QIcon(thumb);
if (auto ptr = m_model.lock()) {
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::DataThumbnail);
{AbstractProjectItem::DataThumbnail});
}
if (!inCache && (m_clipType == ClipType::Text || m_clipType == ClipType::TextTemplate)) {
// Title clips always use the same thumb as bin, refresh
......@@ -512,7 +513,7 @@ QPixmap ProjectClip::thumbnail(int width, int height)
bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool generateThumb)
{
qDebug() << "################### ProjectClip::setproducer";
qDebug() << "################### ProjectClip::setproducer #################";
QMutexLocker locker(&m_producerMutex);
FileStatus::ClipStatus currentStatus = m_clipStatus;
updateProducer(producer);
......@@ -537,14 +538,17 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool gene
}
m_duration = getStringDuration();
m_clipStatus = m_usesProxy ? FileStatus::StatusProxy : FileStatus::StatusReady;
QVector<int>updateRoles;
if (m_clipStatus != currentStatus) {
updateRoles = {AbstractProjectItem::ClipStatus, AbstractProjectItem::IconOverlay};
updateTimelineClips({TimelineModel::StatusRole});
}
setTags(getProducerProperty(QStringLiteral("kdenlive:tags")));
AbstractProjectItem::setRating(uint(getProducerIntProperty(QStringLiteral("kdenlive:rating"))));
if (auto ptr = m_model.lock()) {
updateRoles << AbstractProjectItem::DataDuration;
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::DataDuration);
updateRoles);
std::static_pointer_cast<ProjectItemModel>(ptr)->updateWatcher(std::static_pointer_cast<ProjectClip>(shared_from_this()));
}
// Make sure we have a hash for this clip
......@@ -649,7 +653,7 @@ std::shared_ptr<Mlt::Producer> ProjectClip::thumbProducer()
if (m_thumbsProducer) {
return m_thumbsProducer;
}
if (clipType() == ClipType::Unknown || m_masterProducer == nullptr) {
if (clipType() == ClipType::Unknown || m_masterProducer == nullptr || m_clipStatus == FileStatus::StatusWaiting) {
return nullptr;
}
QMutexLocker lock(&m_thumbMutex);
......@@ -1269,7 +1273,7 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
m_description = properties.value(QStringLiteral("templatetext"));
if (auto ptr = m_model.lock())
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::ClipStatus);
{AbstractProjectItem::ClipStatus});
refreshPanel = true;
}
// Some properties also need to be passed to track producers
......@@ -1362,7 +1366,7 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
m_duration = getStringDuration();
if (auto ptr = m_model.lock())
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::DataDuration);
{AbstractProjectItem::DataDuration});
refreshOnly = false;
reload = true;
}
......@@ -1371,7 +1375,7 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
setTags(properties.value(QStringLiteral("kdenlive:tags")));
if (auto ptr = m_model.lock()) {
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::DataTag);
{AbstractProjectItem::DataTag});
}
refreshRoles << TimelineModel::TagRole;
}
......@@ -1380,7 +1384,7 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
refreshPanel = true;
if (auto ptr = m_model.lock()) {
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::DataName);
{AbstractProjectItem::DataName});
}
refreshRoles << TimelineModel::NameRole;
}
......@@ -2006,7 +2010,7 @@ void ProjectClip::setClipStatus(FileStatus::ClipStatus status)
updateTimelineClips({TimelineModel::StatusRole});
if (auto ptr = m_model.lock()) {
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this()),
AbstractProjectItem::IconOverlay);
{AbstractProjectItem::IconOverlay});
}
}
......
......@@ -356,14 +356,14 @@ QMimeData *ProjectItemModel::mimeData(const QModelIndexList &indices) const
return mimeData;
}
void ProjectItemModel::onItemUpdated(const std::shared_ptr<AbstractProjectItem> &item, int role)
void ProjectItemModel::onItemUpdated(const std::shared_ptr<AbstractProjectItem> &item, const QVector<int> &roles)
{
QWriteLocker locker(&m_lock);
auto tItem = std::static_pointer_cast<TreeItem>(item);
auto ptr = tItem->parentItem().lock();
if (ptr) {
auto index = getIndexFromItem(tItem);
emit dataChanged(index, index, {role});
emit dataChanged(index, index, roles);
}
}
......@@ -372,7 +372,7 @@ void ProjectItemModel::onItemUpdated(const QString &binId, int role)
QWriteLocker locker(&m_lock);
std::shared_ptr<AbstractProjectItem> item = getItemByBinId(binId);
if (item) {
onItemUpdated(item, role);
onItemUpdated(item, {role});
}
}
......
......@@ -228,7 +228,7 @@ protected:
public slots:
/** @brief An item in the list was modified, notify */
void onItemUpdated(const std::shared_ptr<AbstractProjectItem> &item, int role);
void onItemUpdated(const std::shared_ptr<AbstractProjectItem> &item, const QVector<int> &roles);
void onItemUpdated(const QString &binId, int role);
void setDragType(PlaylistState::ClipState type);
......
......@@ -147,7 +147,7 @@ void ProjectSubClip::setThumbnail(const QImage &img)
m_thumbnail = QIcon(thumb);
if (auto ptr = m_model.lock())
std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectSubClip>(shared_from_this()),
AbstractProjectItem::DataThumbnail);
{AbstractProjectItem::DataThumbnail});
}
QPixmap ProjectSubClip::thumbnail(int width, int height)
......
......@@ -60,7 +60,7 @@ void AbstractTask::cancelJob(bool softDelete)
if (softDelete) {
m_softDelete.testAndSetAcquire(0, 1);
}
qDebug()<<"====== SETTING TACK CANCELED: "<<m_isCanceled;
qDebug()<<"====== SETTING TASK CANCELED: "<<m_isCanceled;
emit jobCanceled();
}
......
......@@ -55,7 +55,7 @@ void ClipLoadTask::start(const ObjectId &owner, const QDomElement &xml, bool thu
task = nullptr;
}
if (task) {
// Otherwise, start a new audio levels generation thread.
// Otherwise, start a new load task thread.
task->m_isForce = force;
connect(task, &ClipLoadTask::taskDone, [readyCallBack]() {
QMetaObject::invokeMethod(qApp, [readyCallBack]{ readyCallBack();});
......
......@@ -72,7 +72,7 @@ bool TaskManager::hasPendingJob(const ObjectId &owner, AbstractTask::JOBTYPE typ
}
std::vector<AbstractTask*> taskList = m_taskList.at(owner.second);
for (AbstractTask* t : taskList) {
if (type == t->m_type && t->m_progress < 100) {
if (type == t->m_type && t->m_progress < 100 && !t->m_isCanceled) {
return true;
}
}
......
Markdown is supported
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