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

Fix replacing AV clip with playlist clip broken.

Related to #1216
parent d2937a31
......@@ -1645,8 +1645,10 @@ void Bin::slotReplaceClip()
QMap <QString, QString> sourceProps;
QMap <QString, QString> newProps;
sourceProps.insert(QStringLiteral("resource"), currentItem->url());
sourceProps.insert(QStringLiteral("kdenlive:originalurl"), currentItem->url());
sourceProps.insert(QStringLiteral("kdenlive:clipname"), currentItem->clipName());
newProps.insert(QStringLiteral("resource"), fileName);
newProps.insert(QStringLiteral("kdenlive:originalurl"), fileName);
newProps.insert(QStringLiteral("kdenlive:clipname"), QFileInfo(fileName).fileName());
// Check if replacement clip is long enough
if (currentItem->hasLimitedDuration() && currentItem->isIncludedInTimeline()) {
......
......@@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "projectfolder.h"
#include "projectitemmodel.h"
#include "projectsubclip.h"
#include "clipcreator.hpp"
#include "timecode.h"
#include "timeline2/model/snapmodel.hpp"
#include "macros.hpp"
......@@ -387,11 +388,17 @@ void ProjectClip::reloadProducer(bool refreshOnly, bool isProxy, bool forceAudio
// If another load job is running?
pCore->taskManager.discardJobs({ObjectType::BinClip, m_binId.toInt()}, AbstractTask::LOADJOB, true);
pCore->taskManager.discardJobs({ObjectType::BinClip, m_binId.toInt()}, AbstractTask::CACHEJOB);
if (QFile::exists(m_path) && (!isProxy && !hasProxy())) {
if (QFile::exists(m_path) && (!isProxy && !hasProxy()) && m_properties) {
clearBackupProperties();
}
QDomDocument doc;
QDomElement xml = toXml(doc);
QDomElement xml;
QString resource(m_properties->get("resource"));
if (m_service.isEmpty() && !resource.isEmpty()) {
xml = ClipCreator::getXmlFromUrl(resource).documentElement();
} else {
xml = toXml(doc);
}
if (!xml.isNull()) {
bool hashChanged = false;
m_thumbsProducer.reset();
......@@ -1241,7 +1248,9 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
} else if (!properties.contains("kdenlive:proxy")) {
// Clip resource changed, update thumbnail, name, clear hash
refreshOnly = false;
getInfoForProducer();
// Enforce reloading clip type in case of clip replacement
m_service.clear();
m_clipType = ClipType::Unknown;
updateRoles << TimelineModel::ResourceRole << TimelineModel::MaxDurationRole << TimelineModel::NameRole;
}
}
......@@ -1353,7 +1362,7 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
refreshPanel = true;
}
}
if (refreshPanel) {
if (refreshPanel && m_properties) {
// Some of the clip properties have changed through a command, update properties panel
emit refreshPropertiesPanel();
}
......
......@@ -338,7 +338,6 @@ QMap<QString, QString> ClipController::getPropertiesFromPrefix(const QString &pr
void ClipController::updateProducer(const std::shared_ptr<Mlt::Producer> &producer)
{
qDebug() << "################### ClipController::updateProducer";
// TODO replace all track producers
if (!m_properties) {
// producer has not been initialized
return addMasterProducer(producer);
......@@ -371,6 +370,9 @@ void ClipController::updateProducer(const std::shared_ptr<Mlt::Producer> &produc
setProducerProperty(QStringLiteral("kdenlive:id"), m_controllerBinId);
m_effectStack->resetService(m_masterProducer);
emitProducerChanged(m_controllerBinId, producer);
if (m_clipType == ClipType::Unknown) {
getInfoForProducer();
}
// URL and name should not be updated otherwise when proxying a clip we cannot find back the original url
/*m_url = QUrl::fromLocalFile(m_masterProducer->get("resource"));
if (m_url.isValid()) {
......
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