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

On project close, ensure non loaded clips don't leak to the new project (part 2)

parent 646a4d1f
Pipeline #141938 passed with stage
in 14 minutes and 52 seconds
......@@ -215,6 +215,7 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
QList<QUrl> cleanList;
QStringList duplicates;
bool firstClip = topLevel;
const QUuid uuid = model->uuid();
pCore->bin()->shouldCheckProfile = (KdenliveSettings::default_profile().isEmpty() || KdenliveSettings::checkfirstprojectclip()) && pCore->bin()->isEmpty();
for (const QUrl &url : list) {
if (!pCore->projectItemModel()->urlExists(url.toLocalFile()) || QFileInfo(url.toLocalFile()).isDir()) {
......@@ -238,6 +239,11 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
int current = 0;
for (const QUrl &file : qAsConst(cleanList)) {
current++;
if (model->uuid() != uuid) {
// Project was closed, abort
pCore->displayMessage(QString(), OperationCompletedMessage, 100);
return QString();
}
if (!QFile::exists(file.toLocalFile())) {
continue;
}
......@@ -358,6 +364,11 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
};
firstClip = false;
}
if (model->uuid() != uuid) {
// Project was closed, abort
pCore->displayMessage(QString(), OperationCompletedMessage, 100);
return QString();
}
const QString clipId = ClipCreator::createClipFromFile(file.toLocalFile(), parentFolder, model, undo, redo, callBack);
if (createdItem.isEmpty() && clipId != QLatin1String("-1")) {
createdItem = clipId;
......
......@@ -42,6 +42,7 @@ ProjectItemModel::ProjectItemModel(QObject *parent)
, m_nextId(1)
, m_blankThumb()
, m_dragType(PlaylistState::Disabled)
, m_uuid(QUuid::createUuid())
{
QPixmap pix(QSize(160, 90));
pix.fill(Qt::lightGray);
......@@ -514,6 +515,7 @@ void ProjectItemModel::clean()
}
Q_ASSERT(rootItem->childCount() == 0);
m_nextId = 1;
m_uuid = QUuid::createUuid();
m_fileWatcher->clear();
}
......
......@@ -18,6 +18,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include <QIcon>
#include <QReadWriteLock>
#include <QSize>
#include <QUuid>
class AbstractProjectItem;
class BinPlaylist;
......@@ -206,6 +207,8 @@ public:
int clipsCount() const;
/** @brief Check if a file is already in Bin */
bool urlExists(const QString &path) const;
/** @brief Check if a file is already in Bin */
Please register or sign in to reply
QUuid uuid() const { return m_uuid; };
protected:
/** @brief Register the existence of a new element
......@@ -247,6 +250,8 @@ private:
int m_nextId;
QIcon m_blankThumb;
PlaylistState::ClipState m_dragType;
QUuid m_uuid;
signals:
/** @brief thumbs of the given clip were modified, request update of the monitor if need be */
void refreshAudioThumbs(const QString &id);
......
......@@ -139,7 +139,6 @@ void TaskManager::slotCancelJobs()
void TaskManager::startTask(int ownerId, AbstractTask *task)
{
m_tasksListLock.lockForWrite();
qDebug()<<"========== STARTING TASK FOR: "<<ownerId;
if (m_taskList.find(ownerId) == m_taskList.end()) {
// First task for this clip
m_taskList[ownerId] = {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