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

Ensure queued tasks are not started on project or test close

parent 6e6d06dd
......@@ -23,6 +23,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "projectclip.h"
#include "projectfolder.h"
#include "projectsubclip.h"
#include "utils/thumbnailcache.hpp"
#include "xml/xml.hpp"
#include <KLocalizedString>
......@@ -512,7 +513,7 @@ QStringList ProjectItemModel::getEnclosingFolderInfo(const QModelIndex &index) c
void ProjectItemModel::clean()
{
QWriteLocker locker(&m_lock);
// QWriteLocker locker(&m_lock);
std::vector<std::shared_ptr<AbstractProjectItem>> toDelete;
toDelete.reserve(size_t(rootItem->childCount()));
for (int i = 0; i < rootItem->childCount(); ++i) {
......@@ -527,6 +528,7 @@ void ProjectItemModel::clean()
m_nextId = 1;
m_uuid = QUuid::createUuid();
m_fileWatcher->clear();
ThumbnailCache::get()->clearCache();
}
std::shared_ptr<ProjectFolder> ProjectItemModel::getRootFolder() const
......
......@@ -286,13 +286,18 @@ void ClipLoadTask::generateThumbnail(std::shared_ptr<ProjectClip> binClip, std::
p.drawText(0, 0, fullWidth, imageHeight, Qt::AlignCenter, i18n("Invalid"));
QMetaObject::invokeMethod(binClip.get(), "setThumbnail", Qt::QueuedConnection, Q_ARG(QImage, result), Q_ARG(int, m_in),
Q_ARG(int, m_out), Q_ARG(bool, false));
} else if (binClip.get()) {
} else if (binClip.get() && !m_isCanceled) {
// We don't follow m_isCanceled there,
qDebug() << "=== GOT THUMB FOR: " << m_in << "x" << m_out;
QMetaObject::invokeMethod(binClip.get(), "setThumbnail", Qt::QueuedConnection, Q_ARG(QImage, result), Q_ARG(int, m_in),
Q_ARG(int, m_out), Q_ARG(bool, false));
ThumbnailCache::get()->storeThumbnail(QString::number(m_owner.second), frameNumber, result, false);
}
if (m_isCanceled) {
abort();
} else {
pCore->taskManager.taskDone(m_owner.second, this);
}
}
}
}
......@@ -301,19 +306,20 @@ void ClipLoadTask::generateThumbnail(std::shared_ptr<ProjectClip> binClip, std::
void ClipLoadTask::run()
{
// 2 channels interleaved of uchar values
if (m_isCanceled) {
if (m_isCanceled || pCore->taskManager.isBlocked()) {
abort();
return;
}
// QThread::currentThread()->setPriority(QThread::HighestPriority);
if (m_thumbOnly) {
auto binClip = pCore->projectItemModel()->getClipByBinID(QString::number(m_owner.second));
if (binClip) {
if (binClip && binClip->statusReady()) {
generateThumbnail(binClip, binClip->originalProducer());
return;
} else {
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
m_running = true;
emit pCore->projectItemModel()->resetPlayOrLoopZone(QString::number(m_owner.second));
......
......@@ -147,6 +147,7 @@ void TaskManager::slotCancelJobs(const QVector<AbstractTask::JOBTYPE> exceptions
m_taskPool.waitForDone();
m_transcodePool.waitForDone();
}
m_taskList.clear();
m_blockUpdates = false;
updateJobCount();
}
......
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