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

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