Dont remember clip duration in case of profile change. Fixes #145

parent a1b45e5c
......@@ -169,7 +169,7 @@ public:
/** @brief Sets a new description. */
virtual void setDescription(const QString &description);
virtual QDomElement toXml(QDomDocument &document, bool includeMeta = false) = 0;
virtual QDomElement toXml(QDomDocument &document, bool includeMeta = false, bool includeProfile = true) = 0;
virtual QString getToolTip() const = 0;
virtual bool rename(const QString &name, int column) = 0;
......
......@@ -2951,10 +2951,12 @@ void Bin::reloadAllProducers()
emit openClip(std::shared_ptr<ProjectClip>());
for (const std::shared_ptr<ProjectClip> &clip : clipList) {
QDomDocument doc;
QDomElement xml = clip->toXml(doc);
QDomElement xml = clip->toXml(doc, false, false);
// Make sure we reload clip length
xml.removeAttribute(QStringLiteral("out"));
Xml::removeXmlProperty(xml, QStringLiteral("length"));
clip->resetProducerProperty(QStringLiteral("kdenlive:duration"));
clip->resetProducerProperty(QStringLiteral("length"));
if (!xml.isNull()) {
clip->setClipStatus(AbstractProjectItem::StatusWaiting);
clip->discardAudioThumb();
......
......@@ -340,9 +340,9 @@ void ProjectClip::reloadProducer(bool refreshOnly, bool audioStreamChanged)
}
}
QDomElement ProjectClip::toXml(QDomDocument &document, bool includeMeta)
QDomElement ProjectClip::toXml(QDomDocument &document, bool includeMeta, bool includeProfile)
{
getProducerXML(document, includeMeta);
getProducerXML(document, includeMeta, includeProfile);
QDomElement prod = document.documentElement().firstChildElement(QStringLiteral("producer"));
if (m_clipType != ClipType::Unknown) {
prod.setAttribute(QStringLiteral("type"), (int)m_clipType);
......
......@@ -132,7 +132,7 @@ public:
bool rename(const QString &name, int column) override;
QDomElement toXml(QDomDocument &document, bool includeMeta = false) override;
QDomElement toXml(QDomDocument &document, bool includeMeta = false, bool includeProfile = true) override;
QVariant getData(DataType type) const override;
......
......@@ -144,7 +144,7 @@ void ProjectFolder::setBinEffectsEnabled(bool enabled)
}
}
QDomElement ProjectFolder::toXml(QDomDocument &document, bool)
QDomElement ProjectFolder::toXml(QDomDocument &document, bool, bool)
{
QDomElement folder = document.createElement(QStringLiteral("folder"));
folder.setAttribute(QStringLiteral("name"), name());
......
......@@ -77,7 +77,7 @@ public:
std::shared_ptr<ProjectClip> clipAt(int index) override;
/** @brief Returns an xml description of the folder. */
QDomElement toXml(QDomDocument &document, bool includeMeta = false) override;
QDomElement toXml(QDomDocument &document, bool includeMeta = false, bool includeProfile = true) override;
QString getToolTip() const override;
bool rename(const QString &name, int column) override;
/** @brief Returns a list of all children and sub-children clips. */
......
......@@ -67,7 +67,7 @@ std::shared_ptr<ProjectClip> ProjectFolderUp::clipAt(int index)
void ProjectFolderUp::setBinEffectsEnabled(bool) {}
QDomElement ProjectFolderUp::toXml(QDomDocument &document, bool)
QDomElement ProjectFolderUp::toXml(QDomDocument &document, bool, bool)
{
return document.documentElement();
}
......
......@@ -70,7 +70,7 @@ public:
void setBinEffectsEnabled(bool enabled) override;
/** @brief Returns an xml description of the folder. */
QDomElement toXml(QDomDocument &document, bool includeMeta = false) override;
QDomElement toXml(QDomDocument &document, bool includeMeta = false, bool includeProfile = true) override;
QString getToolTip() const override;
bool rename(const QString &name, int column) override;
ClipType::ProducerType clipType() const override;
......
......@@ -116,7 +116,7 @@ std::shared_ptr<ProjectClip> ProjectSubClip::clipAt(int ix)
return std::shared_ptr<ProjectClip>();
}
QDomElement ProjectSubClip::toXml(QDomDocument &document, bool)
QDomElement ProjectSubClip::toXml(QDomDocument &document, bool, bool)
{
QDomElement sub = document.createElement(QStringLiteral("subclip"));
sub.setAttribute(QStringLiteral("id"), m_masterClip->AbstractProjectItem::clipId());
......
......@@ -65,7 +65,7 @@ public:
std::shared_ptr<ProjectClip> clipAt(int ix) override;
/** @brief Recursively disable/enable bin effects. */
void setBinEffectsEnabled(bool enabled) override;
QDomElement toXml(QDomDocument &document, bool includeMeta = false) override;
QDomElement toXml(QDomDocument &document, bool includeMeta = false, bool includeProfile = true) override;
/** @brief Returns the clip's duration. */
GenTime duration() const;
......
......@@ -136,7 +136,7 @@ void ClipController::addMasterProducer(const std::shared_ptr<Mlt::Producer> &pro
}
namespace {
QString producerXml(const std::shared_ptr<Mlt::Producer> &producer, bool includeMeta)
QString producerXml(const std::shared_ptr<Mlt::Producer> &producer, bool includeMeta, bool includeProfile)
{
Mlt::Consumer c(*producer->profile(), "xml", "string");
Mlt::Service s(producer->get_service());
......@@ -151,6 +151,9 @@ QString producerXml(const std::shared_ptr<Mlt::Producer> &producer, bool include
if (!includeMeta) {
c.set("no_meta", 1);
}
if (!includeProfile) {
c.set("no_profile", 1);
}
c.set("store", "kdenlive");
c.set("no_root", 1);
c.set("root", "/");
......@@ -163,11 +166,11 @@ QString producerXml(const std::shared_ptr<Mlt::Producer> &producer, bool include
}
} // namespace
void ClipController::getProducerXML(QDomDocument &document, bool includeMeta)
void ClipController::getProducerXML(QDomDocument &document, bool includeMeta, bool includeProfile)
{
// TODO refac this is a probable duplicate with Clip::xml
if (m_masterProducer) {
QString xml = producerXml(m_masterProducer, includeMeta);
QString xml = producerXml(m_masterProducer, includeMeta, includeProfile);
document.setContent(xml);
} else {
qCDebug(KDENLIVE_LOG) << " + + ++ NO MASTER PROD";
......@@ -310,8 +313,10 @@ void ClipController::updateProducer(const std::shared_ptr<Mlt::Producer> &produc
} else {
m_usesProxy = false;
}
// When resetting profile, duration can change so we invalidate it to 0 in that case
int length = m_properties->get_int("length");
const char *passList = getPassPropertiesList(m_usesProxy && length > 0);
// This is necessary as some properties like set.test_audio are reset on producer creation
const char *passList = getPassPropertiesList(m_usesProxy);
passProperties.pass_list(*m_properties, passList);
delete m_properties;
*m_masterProducer = producer.get();
......
......@@ -72,7 +72,7 @@ public:
/** @brief Replaces the master producer and (TODO) the track producers with an updated producer, for example a proxy */
void updateProducer(const std::shared_ptr<Mlt::Producer> &producer);
void getProducerXML(QDomDocument &document, bool includeMeta = false);
void getProducerXML(QDomDocument &document, bool includeMeta = false, bool includeProfile = true);
/** @brief Returns a clone of our master producer. Delete after use! */
Mlt::Producer *masterProducer();
......
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