Ensure project clip backup url is correctly updated on replace clip

parent 08485f1b
Pipeline #23298 passed with stage
in 9 minutes and 38 seconds
......@@ -1003,6 +1003,21 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
passProperties.insert(i.key(), i.value());
}
}
if (properties.contains(QStringLiteral("resource"))) {
// Clip source was changed, update important stuff
refreshPanel = true;
reload = true;
if (m_clipType == ClipType::Color) {
refreshOnly = true;
updateRoles << TimelineModel::ResourceRole;
} else {
// Clip resource changed, update thumbnail, name, clear hash
refreshOnly = false;
resetProducerProperty(QStringLiteral("kdenlive:file_hash"));
getInfoForProducer();
updateRoles << TimelineModel::ResourceRole << TimelineModel::MaxDurationRole << TimelineModel::NameRole;
}
}
if (properties.contains(QStringLiteral("kdenlive:proxy"))) {
QString value = properties.value(QStringLiteral("kdenlive:proxy"));
// If value is "-", that means user manually disabled proxy on this clip
......@@ -1028,18 +1043,6 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
if (forceReloadProperties.contains(k)) {
refreshPanel = true;
reload = true;
if (m_clipType == ClipType::Color) {
refreshOnly = true;
updateRoles << TimelineModel::ResourceRole;
} else {
// Clip resource changed, update thumbnail, name, clear hash
refreshOnly = false;
if (propKeys.contains(QStringLiteral("resource"))) {
resetProducerProperty(QStringLiteral("kdenlive:file_hash"));
setProducerProperty(QStringLiteral("kdenlive:originalurl"), url());
updateRoles << TimelineModel::ResourceRole << TimelineModel::MaxDurationRole << TimelineModel::NameRole;
}
}
break;
}
}
......
......@@ -62,33 +62,6 @@ ClipController::ClipController(const QString &clipId, const std::shared_ptr<Mlt:
}
if (m_properties) {
setProducerProperty(QStringLiteral("kdenlive:id"), m_controllerBinId);
m_service = m_properties->get("mlt_service");
if (m_service == QLatin1String("qtext")) {
// Placeholder clip, find real service
QString originalService = m_properties->get("kdenlive:orig_service");
if (!originalService.isEmpty()) {
m_service = originalService;
}
}
QString proxy = m_properties->get("kdenlive:proxy");
QString path = m_properties->get("resource");
if (proxy.length() > 2) {
if (QFileInfo(path).isRelative()) {
path.prepend(pCore->currentDoc()->documentRoot());
m_properties->set("resource", path.toUtf8().constData());
}
// This is a proxy producer, read original url from kdenlive property
path = m_properties->get("kdenlive:originalurl");
if (QFileInfo(path).isRelative()) {
path.prepend(pCore->currentDoc()->documentRoot());
}
m_usesProxy = true;
} else if (m_service != QLatin1String("color") && m_service != QLatin1String("colour") && !path.isEmpty() && QFileInfo(path).isRelative() &&
path != QLatin1String("<producer>")) {
path.prepend(pCore->currentDoc()->documentRoot());
m_properties->set("resource", path.toUtf8().constData());
}
m_path = path.isEmpty() ? QString() : QFileInfo(path).absoluteFilePath();
getInfoForProducer();
checkAudioVideo();
} else {
......@@ -115,7 +88,6 @@ const std::unique_ptr<AudioStreamInfo> &ClipController::audioInfo() const
void ClipController::addMasterProducer(const std::shared_ptr<Mlt::Producer> &producer)
{
qDebug() << "################### ClipController::addmasterproducer";
QString documentRoot = pCore->currentDoc()->documentRoot();
m_masterProducer = producer;
m_properties = new Mlt::Properties(m_masterProducer->get_properties());
m_producerLock.unlock();
......@@ -144,21 +116,6 @@ void ClipController::addMasterProducer(const std::shared_ptr<Mlt::Producer> &pro
} else {
checkAudioVideo();
setProducerProperty(QStringLiteral("kdenlive:id"), m_controllerBinId);
QString proxy = m_properties->get("kdenlive:proxy");
m_service = m_properties->get("mlt_service");
QString path = m_properties->get("resource");
m_usesProxy = false;
if (proxy.length() > 2) {
// This is a proxy producer, read original url from kdenlive property
path = m_properties->get("kdenlive:originalurl");
if (QFileInfo(path).isRelative()) {
path.prepend(documentRoot);
}
m_usesProxy = true;
} else if (m_service != QLatin1String("color") && m_service != QLatin1String("colour") && !path.isEmpty() && QFileInfo(path).isRelative()) {
path.prepend(documentRoot);
}
m_path = path.isEmpty() ? QString() : QFileInfo(path).absoluteFilePath();
getInfoForProducer();
emitProducerChanged(m_controllerBinId, producer);
}
......@@ -215,6 +172,37 @@ void ClipController::getProducerXML(QDomDocument &document, bool includeMeta, bo
void ClipController::getInfoForProducer()
{
QReadLocker lock(&m_producerLock);
m_service = m_properties->get("mlt_service");
if (m_service == QLatin1String("qtext")) {
// Placeholder clip, find real service
QString originalService = m_properties->get("kdenlive:orig_service");
if (!originalService.isEmpty()) {
m_service = originalService;
}
}
QString proxy = m_properties->get("kdenlive:proxy");
QString path = m_properties->get("resource");
if (proxy.length() > 2) {
if (QFileInfo(path).isRelative()) {
path.prepend(pCore->currentDoc()->documentRoot());
m_properties->set("resource", path.toUtf8().constData());
}
// This is a proxy producer, read original url from kdenlive property
path = m_properties->get("kdenlive:originalurl");
if (QFileInfo(path).isRelative()) {
path.prepend(pCore->currentDoc()->documentRoot());
}
m_usesProxy = true;
} else if (m_service != QLatin1String("color") && m_service != QLatin1String("colour") && !path.isEmpty() && QFileInfo(path).isRelative() &&
path != QLatin1String("<producer>")) {
path.prepend(pCore->currentDoc()->documentRoot());
m_properties->set("resource", path.toUtf8().constData());
}
m_path = path.isEmpty() ? QString() : QFileInfo(path).absoluteFilePath();
QString origurl = m_properties->get("kdenlive:originalurl");
if (!origurl.isEmpty()) {
m_properties->set("kdenlive:originalurl", m_path.toUtf8().constData());
}
date = QFileInfo(m_path).lastModified();
m_videoIndex = -1;
int audioIndex = -1;
......
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