Various proxy fixes:

enable/disable option in clip properties when changed in project settings
Fix proxy file not deleted on abort job
Don't reload clip on projy job abort
parent 181c6a4c
......@@ -2920,6 +2920,10 @@ void Bin::refreshProxySettings()
QList<std::shared_ptr<ProjectClip>> clipList = m_itemModel->getRootFolder()->childClips();
auto *masterCommand = new QUndoCommand();
masterCommand->setText(m_doc->useProxy() ? i18n("Enable proxies") : i18n("Disable proxies"));
// en/disable proxy option in clip properties
for (QWidget *w : m_propertiesPanel->findChildren<ClipPropertiesController *>()) {
static_cast<ClipPropertiesController *>(w)->enableProxy(m_doc->useProxy());
}
if (!m_doc->useProxy()) {
// Disable all proxies
m_doc->slotProxyCurrentItem(false, clipList, false, masterCommand);
......
......@@ -827,9 +827,14 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
// If value is "-", that means user manually disabled proxy on this clip
if (value.isEmpty() || value == QLatin1String("-")) {
// reset proxy
pCore->jobManager()->discardJobs(clipId(), AbstractClipJob::PROXYJOB);
reload = true;
refreshOnly = false;
int id;
if (pCore->jobManager()->hasPendingJob(clipId(), AbstractClipJob::PROXYJOB, &id)) {
// The proxy clip is being created, abort
pCore->jobManager()->discardJobs(clipId(), AbstractClipJob::PROXYJOB);
} else {
reload = true;
refreshOnly = false;
}
} else {
// A proxy was requested, make sure to keep original url
setProducerProperty(QStringLiteral("kdenlive:originalurl"), url());
......
......@@ -94,6 +94,7 @@ protected:
signals:
// send an int between 0 and 100 to reflect computation progress
void jobProgress(int);
void jobCanceled();
};
#endif
......@@ -100,6 +100,9 @@ void JobManager::discardJobs(const QString &binId, AbstractClipJob::JOBTYPE type
}
for (int jobId : m_jobsByClip.at(binId)) {
if (type == AbstractClipJob::NOJOBTYPE || m_jobs.at(jobId)->m_type == type) {
for (std::shared_ptr<AbstractClipJob>job : m_jobs.at(jobId)->m_job) {
job->jobCanceled();
}
m_jobs.at(jobId)->m_future.cancel();
}
}
......@@ -183,6 +186,9 @@ void JobManager::slotDiscardClipJobs(const QString &binId)
if (m_jobsByClip.count(binId) > 0) {
for (int jobId : m_jobsByClip.at(binId)) {
Q_ASSERT(m_jobs.count(jobId) > 0);
for (std::shared_ptr<AbstractClipJob>job : m_jobs.at(jobId)->m_job) {
job->jobCanceled();
}
m_jobs[jobId]->m_future.cancel();
}
}
......@@ -193,6 +199,9 @@ void JobManager::slotCancelPendingJobs()
QWriteLocker locker(&m_lock);
for (const auto &j : m_jobs) {
if (!j.second->m_future.isStarted()) {
for (std::shared_ptr<AbstractClipJob>job : j.second->m_job) {
job->jobCanceled();
}
j.second->m_future.cancel();
}
}
......@@ -202,6 +211,9 @@ void JobManager::slotCancelJobs()
{
QWriteLocker locker(&m_lock);
for (const auto &j : m_jobs) {
for (std::shared_ptr<AbstractClipJob>job : j.second->m_job) {
job->jobCanceled();
}
j.second->m_future.cancel();
}
}
......
......@@ -138,6 +138,7 @@ bool ProxyJob::startJob()
m_jobProcess = new QProcess;
m_jobProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(this, &ProxyJob::jobCanceled, m_jobProcess, &QProcess::kill, Qt::DirectConnection);
connect(m_jobProcess, &QProcess::readyReadStandardOutput, this, &ProxyJob::processLogInfo);
m_jobProcess->start(KdenliveSettings::rendererpath(), mltParameters);
m_jobProcess->waitForFinished(-1);
......@@ -260,6 +261,7 @@ bool ProxyJob::startJob()
m_jobProcess = new QProcess;
m_jobProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(m_jobProcess, &QProcess::readyReadStandardOutput, this, &ProxyJob::processLogInfo);
connect(this, &ProxyJob::jobCanceled, m_jobProcess, &QProcess::kill, Qt::DirectConnection);
m_jobProcess->start(KdenliveSettings::ffmpegpath(), parameters, QIODevice::ReadOnly);
m_jobProcess->waitForFinished(-1);
result = m_jobProcess->exitStatus() == QProcess::NormalExit;
......
......@@ -374,6 +374,7 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
bg->setEnabled(toggled);
setToolTip(m_properties.get("kdenlive:proxy"));
});
connect(this, &ClipPropertiesController::enableProxy, pbox, &QCheckBox::setEnabled);
connect(this, &ClipPropertiesController::proxyModified, [this, pbox, bg] (const QString &pxy) {
pbox->setChecked(pxy.length() > 2);
bg->setEnabled(pbox->isChecked());
......
......@@ -120,6 +120,7 @@ signals:
void requestProxy(bool doProxy);
void proxyModified(const QString &);
void deleteProxy();
void enableProxy(bool);
};
#endif
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