Fix proxy creation not restarting when changing a property while creating proxy

parent 5cd17e33
......@@ -2504,9 +2504,9 @@ void Bin::refreshClipMarkers(const QString &id)
}
}
void Bin::discardJobs(const QString &id, AbstractClipJob::JOBTYPE type)
bool Bin::discardJobs(const QString &id, AbstractClipJob::JOBTYPE type)
{
m_jobManager->discardJobs(id, type);
return m_jobManager->discardJobs(id, type);
}
void Bin::slotStartCutJob(const QString &id)
......
......@@ -214,8 +214,10 @@ public:
/** @brief Start a job of selected type for a clip */
void startJob(const QString &id, AbstractClipJob::JOBTYPE type);
/** @brief Discard jobs from a chosen type, use NOJOBTYPE to discard all jobs for this clip */
void discardJobs(const QString &id, AbstractClipJob::JOBTYPE type = AbstractClipJob::NOJOBTYPE);
/** @brief Discard jobs from a chosen type, use NOJOBTYPE to discard all jobs for this clip
* @returns true if a job was found and discarded
*/
bool discardJobs(const QString &id, AbstractClipJob::JOBTYPE type = AbstractClipJob::NOJOBTYPE);
/** @brief Check if there is a job waiting / running for this clip */
bool hasPendingJob(const QString &id, AbstractClipJob::JOBTYPE type);
......
......@@ -282,8 +282,17 @@ void ProjectClip::reloadProducer(bool refreshOnly)
// set a special flag to request thumbnail only
xml.setAttribute(QStringLiteral("refreshOnly"), QStringLiteral("1"));
} else {
bin()->discardJobs(m_id, AbstractClipJob::PROXYJOB);
if (hasProxy()) {
if (bin()->discardJobs(m_id, AbstractClipJob::PROXYJOB)) {
// A proxy job was running, reset proxy property to trigger proxy creation
QString path = getProducerProperty(QStringLiteral("_proxy"));
if (!path.isEmpty()) {
EffectsList::setProperty(xml, QStringLiteral("kdenlive:proxy"), path.toUtf8().constData());
}
// If we have a proxy, delete it
xml.setAttribute(QStringLiteral("overwriteproxy"), QStringLiteral("1"));
setProducerProperty(QStringLiteral("_overwriteproxy"), QStringLiteral("1"));
}
else if (hasProxy()) {
// If we have a proxy, delete it
xml.setAttribute(QStringLiteral("overwriteproxy"), QStringLiteral("1"));
setProducerProperty(QStringLiteral("_overwriteproxy"), QStringLiteral("1"));
......
......@@ -194,6 +194,8 @@ void ProducerQueue::processFileProperties()
if (QFileInfo(path).size() <= 0 || info.xml.hasAttribute(QStringLiteral("overwriteproxy"))) {
// proxy is missing, re-create it
emit requestProxy(info.clipId);
m_processingClipId.removeAll(info.clipId);
continue;
proxyProducer = false;
//path = info.xml.attribute("resource");
path = ProjectClip::getXmlProperty(info.xml, QStringLiteral("resource"));
......
......@@ -81,7 +81,7 @@ QStringList JobManager::getPendingJobs(const QString &id)
return result;
}
void JobManager::discardJobs(const QString &id, AbstractClipJob::JOBTYPE type)
bool JobManager::discardJobs(const QString &id, AbstractClipJob::JOBTYPE type)
{
QMutexLocker lock(&m_jobMutex);
bool jobFound = false;
......@@ -96,6 +96,7 @@ void JobManager::discardJobs(const QString &id, AbstractClipJob::JOBTYPE type)
emit updateJobStatus(id, type, JobAborted);
updateJobCount();
}
return jobFound;
}
bool JobManager::hasPendingJob(const QString &clipId, AbstractClipJob::JOBTYPE type)
......
......@@ -50,8 +50,9 @@ public:
/** @brief Discard specific job type for a clip.
* @param id the clip id
* @param type The type of job that you want to abort, leave to NOJOBTYPE to abort all jobs
* @returns true if a job was found and discarded
*/
void discardJobs(const QString &id, AbstractClipJob::JOBTYPE type = AbstractClipJob::NOJOBTYPE);
bool discardJobs(const QString &id, AbstractClipJob::JOBTYPE type = AbstractClipJob::NOJOBTYPE);
/** @brief Check if there is a pending / running job a clip.
* @param id the clip id
......
......@@ -334,11 +334,13 @@ QHash<ProjectClip *, AbstractClipJob *> ProxyJob::prepareJob(Bin *bin, const QLi
local_params.append(QStringLiteral(" -noautorotate"));
}
QString path = item->getProducerProperty(QStringLiteral("kdenlive:proxy"));
if (path.isEmpty()) {
if (path.isEmpty() || path.length() < 3) path = item->getProducerProperty(QStringLiteral("_proxy"));
if (path.isEmpty() || path.length() < 3) {
item->setJobStatus(AbstractClipJob::PROXYJOB, JobCrashed, -1, i18n("Failed to create proxy, empty path."));
continue;
}
// Reset proxy path until it is really created
item->setProducerProperty(QStringLiteral("_proxy"), path.toUtf8().constData());
item->setProducerProperty(QStringLiteral("kdenlive:proxy"), QString());
if (item->getProducerIntProperty(QStringLiteral("_overwriteproxy")) == 0 && QFileInfo(path).size() > 0) {
// Proxy already created
......
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