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

Correctly display info on error with jobs, fix stablize add clip checkbox not working

BUG: 436805
parent 08eecf0b
Pipeline #69196 canceled with stage
......@@ -32,6 +32,8 @@
#include <QTime>
#include <QFile>
#include <QElapsedTimer>
#include <klocalizedstring.h>
#include <KMessageWidget>
static QList<AudioLevelsTask*> tasksList;
static QMutex tasksListMutex;
......@@ -82,9 +84,8 @@ void AudioLevelsTask::run()
}
std::shared_ptr<Mlt::Producer> producer = binClip->originalProducer();
if ((producer == nullptr) || !producer->is_valid()) {
/*m_errorMessage.append(i18n("Audio thumbs: cannot open project file %1", m_binClip->url()));
m_done = true;
m_successful = false;*/
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Audio thumbs: cannot open file %1", binClip->url())),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -144,7 +145,8 @@ void AudioLevelsTask::run()
}
QScopedPointer<Mlt::Producer> audioProducer(new Mlt::Producer(*producer->profile(), service.toUtf8().constData(), producer->get("resource")));
if (!audioProducer->is_valid()) {
//m_errorMessage.append(i18n("Audio thumbs: cannot open file %1", producer->get("resource")));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Audio thumbs: cannot open file %1", producer->get("resource"))),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -218,7 +220,7 @@ void AudioLevelsTask::run()
producer->set(key2.toUtf8().constData(), int(maxLevel));
producer->set(key.toUtf8().constData(), levelsCopy, 0, (mlt_destructor) deleteQVariantList);
producer->unlock();
qDebug()<<"=== FINISHED PRODUCING AUDIO FOR: "<<key<<", SIZE: "<<levelsCopy->size();
//qDebug()<<"=== FINISHED PRODUCING AUDIO FOR: "<<key<<", SIZE: "<<levelsCopy->size();
m_progress = 100;
QMetaObject::invokeMethod(m_object, "updateJobProgress");
QMetaObject::invokeMethod(m_object, "updateAudioThumbnail");
......@@ -243,7 +245,6 @@ void AudioLevelsTask::run()
image.save(cachePath);
}
}
qDebug()<<"============= TASK WAS CANCELED: "<<m_isCanceled<<"\n\n===================";
pCore->taskManager.taskDone(m_owner.second, this);
QMetaObject::invokeMethod(m_object, "updateJobProgress");
}
......@@ -131,13 +131,13 @@ std::shared_ptr<Mlt::Producer> ClipLoadTask::loadPlaylist(QString &resource)
//resource.prepend(QStringLiteral("xml:"));
} else {
// This is currently crashing so I guess we'd better reject it for now
if (!pCore->getCurrentProfile()->isCompatible(xmlProfile.get())) {
m_errorMessage.append(i18n("Playlist has a different framerate (%1/%2fps), not recommended.", xmlProfile->frame_rate_num(), xmlProfile->frame_rate_den()));
if (pCore->getCurrentProfile()->isCompatible(xmlProfile.get())) {
QString loader = resource;
loader.prepend(QStringLiteral("consumer:"));
return std::make_shared<Mlt::Producer>(*pCore->getProjectProfile(), loader.toUtf8().constData());
} else {
m_errorMessage.append(i18n("No matching profile"));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Playlist has a different framerate (%1/%2fps), not supported.", xmlProfile->frame_rate_num(), xmlProfile->frame_rate_den())),
Q_ARG(int, int(KMessageWidget::Warning)));
return nullptr;
}
}
......@@ -451,10 +451,6 @@ void ClipLoadTask::run()
}
case ClipType::Playlist: {
producer = loadPlaylist(resource);
if (!m_errorMessage.isEmpty()) {
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString,m_errorMessage),
Q_ARG(int, int(KMessageWidget::Warning)));
}
if (producer && resource.endsWith(QLatin1String(".kdenlive"))) {
QFile f(resource);
QDomDocument doc;
......@@ -512,7 +508,6 @@ void ClipLoadTask::run()
}
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot open file %1", resource)),
Q_ARG(int, int(KMessageWidget::Warning)));
m_errorMessage.append(i18n("ERROR: Could not load clip %1: producer is invalid", resource));
abort();
return;
}
......@@ -530,7 +525,6 @@ void ClipLoadTask::run()
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot get duration for file %1", resource)),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QList<QAction*>, actions));
m_errorMessage.append(i18n("ERROR: Could not load clip %1: producer is invalid", resource));
abort();
return;
}
......@@ -694,8 +688,14 @@ void ClipLoadTask::abort()
if (!m_softDelete) {
auto binClip = pCore->projectItemModel()->getClipByBinID(QString::number(m_owner.second));
if (binClip) {
binClip->setInvalid();
pCore->projectItemModel()->requestBinClipDeletion(binClip, undo, redo);
if (binClip->hash().isEmpty()) {
// User tried to add an invalid clip, remove it.
binClip->setInvalid();
pCore->projectItemModel()->requestBinClipDeletion(binClip, undo, redo);
} else {
// An existing clip just became invalid, mark it as missing.
binClip->setClipStatus(FileStatus::StatusMissing);
}
}
}
pCore->taskManager.taskDone(m_owner.second, this);
......
......@@ -255,7 +255,6 @@ void CutTask::run()
if (QFileInfo(m_destination).size() == 0) {
QFile::remove(m_destination);
// File was not created
m_logDetails.append(QString::fromUtf8(m_jobProcess->readAll()));
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Failed to create file.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
} else {
......@@ -267,7 +266,6 @@ void CutTask::run()
} else {
// transcode task crashed
QFile::remove(m_destination);
m_logDetails.append(QString::fromUtf8(m_jobProcess->readAll()));
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cut job failed.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
}
......
......@@ -77,7 +77,8 @@ void FilterTask::run()
// Filter applied on a timeline or bin clip
url = binClip->url();
if (url.isEmpty()) {
m_errorMessage.append(i18n("No producer for this clip."));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("No producer for this clip.")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -90,8 +91,9 @@ void FilterTask::run()
producer = std::make_unique<Mlt::Producer>(profile, url.toUtf8().constData());
}
if ((producer == nullptr) || !producer->is_valid()) {
// Clip was removed or something went wrong, Notify user?
m_errorMessage.append(i18n("Invalid clip"));
// Clip was removed or something went wrong
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot open file %1", binClip->url())),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -117,7 +119,8 @@ void FilterTask::run()
if ((producer == nullptr) || !producer->is_valid()) {
// Clip was removed or something went wrong, Notify user?
m_errorMessage.append(i18n("Invalid clip"));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot open source.")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -142,7 +145,8 @@ void FilterTask::run()
destFile.close();
std::unique_ptr<Mlt::Consumer>consumer(new Mlt::Consumer(profile, "xml", sourceFile.fileName().toUtf8().constData()));
if (!consumer->is_valid()) {
m_errorMessage.append(i18n("Cannot create consumer."));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot create consumer.")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -154,7 +158,8 @@ void FilterTask::run()
// Build filter
Mlt::Filter filter(profile, m_filterName.toUtf8().data());
if (!filter.is_valid()) {
m_errorMessage.append(i18n("Cannot create filter %1", m_filterName));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot create filter %1", m_filterName)),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -226,6 +231,10 @@ void FilterTask::run()
}
pCore->taskManager.taskDone(m_owner.second, this);
if (m_isCanceled || !result) {
if (!m_isCanceled) {
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Failed to filter source.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
}
return;
}
......
......@@ -204,7 +204,8 @@ void ProxyTask::run()
QImage i(source);
if (i.isNull()) {
result = false;
m_errorMessage.append(i18n("Cannot load image %1.", source));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot load image %1.", source)),
Q_ARG(int, int(KMessageWidget::Warning)));
m_progress = 100;
pCore->taskManager.taskDone(m_owner.second, this);
QMetaObject::invokeMethod(m_object, "updateJobProgress");
......@@ -263,7 +264,8 @@ void ProxyTask::run()
m_isFfmpegJob = true;
if (!QFileInfo(KdenliveSettings::ffmpegpath()).isFile()) {
// FFmpeg not detected, cannot process the Job
m_errorMessage.prepend(i18n("Failed to create proxy. FFmpeg not found, please set path in Kdenlive's settings Environment"));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("FFmpeg not found, please set path in Kdenlive's settings Environment")),
Q_ARG(int, int(KMessageWidget::Warning)));
result = true;
m_progress = 100;
pCore->taskManager.taskDone(m_owner.second, this);
......@@ -368,7 +370,8 @@ void ProxyTask::run()
QFile::remove(dest);
// File was not created
result = false;
m_errorMessage.append(i18n("Failed to create proxy clip."));
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Failed to create proxy clip.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
if (binClip) {
binClip->setProducerProperty(QStringLiteral("kdenlive:proxy"), QStringLiteral("-"));
}
......@@ -379,7 +382,8 @@ void ProxyTask::run()
} else {
// Proxy process crashed
QFile::remove(dest);
m_errorMessage.append(QString::fromUtf8(m_jobProcess->readAll()));
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Failed to create proxy clip.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
}
return;
}
......
......@@ -127,14 +127,16 @@ void SceneSplitTask::run()
bool result;
if (type != ClipType::AV && type != ClipType::Video) {
// This job can only process video files
m_errorMessage.prepend(i18n("Cannot analyse this clip type"));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot analyse this clip type.")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
qDebug()<<"=== ABORT 1";
return;
}
if (KdenliveSettings::ffmpegpath().isEmpty()) {
// FFmpeg not detected, cannot process the Job
m_errorMessage.prepend(i18n("Failed to create proxy. FFmpeg not found, please set path in Kdenlive's settings Environment"));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("FFmpeg not found, please set path in Kdenlive's settings Environment.")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
qDebug()<<"=== ABORT 2";
return;
......@@ -230,7 +232,8 @@ void SceneSplitTask::run()
}
} else {
// Proxy process crashed
m_errorMessage.append(QString::fromUtf8(m_jobProcess->readAll()));
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Failed to analyse clip.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
}
}
......
......@@ -178,7 +178,8 @@ void SpeedTask::run()
// Filter applied on a timeline or bin clip
url = binClip->url();
if (url.isEmpty()) {
m_errorMessage.append(i18n("No producer for this clip."));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("No producer for this clip.")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -190,6 +191,10 @@ void SpeedTask::run()
producerArgs << QString("out=%1").arg(m_outPoint);
}
} else {
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("No producer for this clip.")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
// Filter applied on a track of master producer, leave config to source job
// We are on master or track, configure producer accordingly
// TODO
......@@ -232,6 +237,10 @@ void SpeedTask::run()
QMetaObject::invokeMethod(m_object, "updateJobProgress");
pCore->taskManager.taskDone(m_owner.second, this);
if (m_isCanceled || !result) {
if (!m_isCanceled) {
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Failed to create speed clip.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
}
return;
}
......
......@@ -38,13 +38,14 @@
#include <klocalizedstring.h>
StabilizeTask::StabilizeTask(const ObjectId &owner, const QString &binId, const QString &destination, int in, int out, std::unordered_map<QString, QVariant> filterParams, QObject* object)
StabilizeTask::StabilizeTask(const ObjectId &owner, const QString &binId, const QString &destination, int in, int out, bool autoAddClip, std::unordered_map<QString, QVariant> filterParams, QObject* object)
: AbstractTask(owner, AbstractTask::STABILIZEJOB, object)
, m_binId(binId)
, m_inPoint(in)
, m_outPoint(out)
, m_filterParams(filterParams)
, m_destination(destination)
, m_addToProject(autoAddClip)
{
}
......@@ -83,14 +84,14 @@ void StabilizeTask::start(QObject* object, bool force)
owner = ObjectId(ObjectType::BinClip, binData.first().toInt());
auto binClip = pCore->projectItemModel()->getClipByBinID(binData.first());
if (binClip) {
task = new StabilizeTask(owner, binData.first(), destinations.at(id), binData.at(1).toInt(), binData.at(2).toInt(), filterParams, binClip.get());
task = new StabilizeTask(owner, binData.first(), destinations.at(id), binData.at(1).toInt(), binData.at(2).toInt(), d->autoAddClip(), filterParams, binClip.get());
}
} else {
// Process full clip
owner = ObjectId(ObjectType::BinClip, id.toInt());
auto binClip = pCore->projectItemModel()->getClipByBinID(id);
if (binClip) {
task = new StabilizeTask(owner, id, destinations.at(id), -1, -1, filterParams, binClip.get());
task = new StabilizeTask(owner, id, destinations.at(id), -1, -1, d->autoAddClip(), filterParams, binClip.get());
}
}
if (task) {
......@@ -118,7 +119,8 @@ void StabilizeTask::run()
// Filter applied on a timeline or bin clip
url = binClip->url();
if (url.isEmpty()) {
m_errorMessage.append(i18n("No producer for this clip."));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("No producer for this clip.")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -133,6 +135,10 @@ void StabilizeTask::run()
// Filter applied on a track of master producer, leave config to source job
// We are on master or track, configure producer accordingly
// TODO
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("No producer for this clip.")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
/*if (m_owner.first == ObjectType::Master) {
producer = pCore->getMasterProducerInstance();
} else if (m_owner.first == ObjectType::TimelineTrack) {
......@@ -182,11 +188,15 @@ void StabilizeTask::run()
QMetaObject::invokeMethod(m_object, "updateJobProgress");
pCore->taskManager.taskDone(m_owner.second, this);
if (m_isCanceled || !result) {
if (!m_isCanceled) {
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Failed to stabilize.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
}
return;
}
QMetaObject::invokeMethod(pCore->bin(), "addProjectClipInFolder", Qt::QueuedConnection, Q_ARG(const QString&,m_destination), Q_ARG(const QString&,binClip->parent()->clipId()), Q_ARG(const QString&,i18n("Stabilized")));
return;
if (m_addToProject) {
QMetaObject::invokeMethod(pCore->bin(), "addProjectClipInFolder", Qt::QueuedConnection, Q_ARG(const QString&,m_destination), Q_ARG(const QString&,binClip->parent()->clipId()), Q_ARG(const QString&,i18n("Stabilized")));
}
}
void StabilizeTask::processLogInfo()
......
......@@ -31,7 +31,7 @@ class QProcess;
class StabilizeTask : public AbstractTask
{
public:
StabilizeTask(const ObjectId &owner, const QString &binId, const QString &destination, int in, int out, std::unordered_map<QString, QVariant> filterParams, QObject* object);
StabilizeTask(const ObjectId &owner, const QString &binId, const QString &destination, int in, int out, bool autoAddClip, std::unordered_map<QString, QVariant> filterParams, QObject* object);
static void start(QObject* object, bool force = false);
int length;
......@@ -51,6 +51,7 @@ private:
QString m_errorMessage;
QString m_logDetails;
std::unique_ptr<QProcess> m_jobProcess;
bool m_addToProject;
};
......
......@@ -157,7 +157,8 @@ void TranscodeTask::run()
QStringList parameters;
if (KdenliveSettings::ffmpegpath().isEmpty()) {
// FFmpeg not detected, cannot process the Job
m_errorMessage.prepend(i18n("Failed to create proxy. FFmpeg not found, please set path in Kdenlive's settings Environment"));
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("FFmpeg not found, please set path in Kdenlive's settings Environment")),
Q_ARG(int, int(KMessageWidget::Warning)));
pCore->taskManager.taskDone(m_owner.second, this);
return;
}
......@@ -200,7 +201,8 @@ void TranscodeTask::run()
if (QFileInfo(destUrl).size() == 0) {
QFile::remove(destUrl);
// File was not created
m_errorMessage.append(i18n("Failed to create file."));
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Failed to create file.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
} else {
QString id = QString::number(m_owner.second);
auto binClip = pCore->projectItemModel()->getClipByBinID(id);
......@@ -227,7 +229,8 @@ void TranscodeTask::run()
} else {
// Proxy process crashed
QFile::remove(destUrl);;
m_errorMessage.append(QString::fromUtf8(m_jobProcess->readAll()));
QMetaObject::invokeMethod(pCore.get(), "displayBinLogMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Failed to create file.")),
Q_ARG(int, int(KMessageWidget::Warning)), Q_ARG(QString, m_logDetails));
}
}
......
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