Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix title clip created with incorrect duration. Fixes #383

parent bd5c9b4f
Pipeline #9266 passed with stage
in 15 minutes and 57 seconds
......@@ -112,7 +112,7 @@ void processProducerProperties(const std::shared_ptr<Mlt::Producer> &prod, const
} // namespace
// static
std::shared_ptr<Mlt::Producer> LoadJob::loadResource(QString &resource, const QString &type)
std::shared_ptr<Mlt::Producer> LoadJob::loadResource(QString resource, const QString &type)
{
if (!resource.startsWith(type)) {
resource.prepend(type);
......@@ -268,14 +268,20 @@ bool LoadJob::startJob()
break;
case ClipType::Text:
case ClipType::TextTemplate: {
m_producer = loadResource(m_resource, QStringLiteral("kdenlivetitle:"));
bool ok;
int producerLength = 0;
QString pLength = Xml::getXmlProperty(m_xml, QStringLiteral("length"));
int producerLength = pLength.toInt(&ok);
if (!ok) {
producerLength = m_producer->time_to_frames(pLength.toUtf8().constData());
if (pLength.isEmpty()) {
producerLength = m_xml.attribute(QStringLiteral("length")).toInt();
} else {
producerLength = pLength.toInt(&ok);
}
m_producer = loadResource(m_resource, QStringLiteral("kdenlivetitle:"));
if (!m_resource.isEmpty()) {
if (!ok) {
producerLength = m_producer->time_to_frames(pLength.toUtf8().constData());
}
// Title from .kdenlivetitle file
QFile txtfile(m_resource);
QDomDocument txtdoc(QStringLiteral("titledocument"));
......@@ -295,8 +301,13 @@ bool LoadJob::startJob()
duration = m_producer->time_to_frames(xmlDuration.toUtf8().constData());
}
}
qDebug()<<"===== GOT PRODUCER DURATION: "<<duration<<"; PROD: "<<producerLength;
if (duration <= 0) {
duration = pCore->currentDoc()->getFramePos(KdenliveSettings::title_duration());
if (producerLength > 0) {
duration = producerLength;
} else {
duration = pCore->currentDoc()->getFramePos(KdenliveSettings::title_duration());
}
}
if (producerLength <= 0) {
producerLength = duration;
......
......@@ -59,7 +59,7 @@ public:
protected:
// helper to load some kind of resources such as color. This will modify resource if needs be (for eg., in the case of color, it will prepend "color:" if
// needed)
static std::shared_ptr<Mlt::Producer> loadResource(QString &resource, const QString &type);
static std::shared_ptr<Mlt::Producer> loadResource(QString resource, const QString &type);
std::shared_ptr<Mlt::Producer> loadPlaylist(QString &resource);
......
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