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 invalid "main bin" xml

parent a85518de
......@@ -27,7 +27,8 @@
#include "projectclip.h"
#include <mlt++/Mlt.h>
QString BinPlaylist::binPlaylistId = QStringLiteral("main bin");
QString BinPlaylist::binPlaylistId = QStringLiteral("main_bin");
BinPlaylist::BinPlaylist()
: m_binPlaylist(new Mlt::Playlist(pCore->getCurrentProfile()->profile()))
{
......
......@@ -778,9 +778,10 @@ void ProjectItemModel::loadBinPlaylist(Mlt::Tractor *documentTractor, Mlt::Tract
clean();
Mlt::Properties retainList((mlt_properties)documentTractor->get_data("xml_retain"));
qDebug() << "Loading bin playlist...";
if (retainList.is_valid() && (retainList.get_data(BinPlaylist::binPlaylistId.toUtf8().constData()) != nullptr)) {
Mlt::Playlist playlist((mlt_playlist)retainList.get_data(BinPlaylist::binPlaylistId.toUtf8().constData()));
Mlt::Playlist playlist;
if (retainList.is_valid()) {
qDebug() << "retain is valid";
Mlt::Playlist playlist((mlt_playlist) retainList.get_data(BinPlaylist::binPlaylistId.toUtf8().constData()));
if (playlist.is_valid() && playlist.type() == playlist_type) {
qDebug() << "playlist is valid";
......
......@@ -21,6 +21,7 @@
#include "effects/effectsrepository.hpp"
#include "kdenlivesettings.h"
#include "kthumb.h"
#include "bin/binplaylist.hpp"
#include "titler/titlewidget.h"
#include "utils/KoIconUtils.h"
......@@ -87,7 +88,7 @@ bool DocumentChecker::hasErrorInClips()
QDir projectDir(m_url.adjusted(QUrl::RemoveFilename).toLocalFile());
QDomNodeList playlists = m_doc.elementsByTagName(QStringLiteral("playlist"));
for (int i = 0; i < playlists.count(); ++i) {
if (playlists.at(i).toElement().attribute(QStringLiteral("id")) == QStringLiteral("main bin")) {
if (playlists.at(i).toElement().attribute(QStringLiteral("id")) == BinPlaylist::binPlaylistId) {
QString documentid = EffectsList::property(playlists.at(i).toElement(), QStringLiteral("kdenlive:docproperties.documentid"));
if (documentid.isEmpty()) {
// invalid document id, recreate one
......
......@@ -24,6 +24,7 @@
#include "effectslist/initeffects.h"
#include "mainwindow.h"
#include "mltcontroller/bincontroller.h"
#include "bin/binplaylist.hpp"
#include "kdenlive_debug.h"
#include <KMessageBox>
......@@ -1180,8 +1181,8 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
}
QDomNode mlt = m_doc.firstChildElement(QStringLiteral("mlt"));
main_playlist.setAttribute(QStringLiteral("id"), pCore->binController()->binPlaylistId());
mlt.toElement().setAttribute(QStringLiteral("producer"), pCore->binController()->binPlaylistId());
main_playlist.setAttribute(QStringLiteral("id"), BinPlaylist::binPlaylistId);
mlt.toElement().setAttribute(QStringLiteral("producer"), BinPlaylist::binPlaylistId);
QStringList ids;
QStringList slowmotionIds;
QDomNode firstProd = m_doc.firstChildElement(QStringLiteral("producer"));
......@@ -1500,7 +1501,7 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
playlists = m_doc.elementsByTagName(QStringLiteral("playlist"));
QDomElement playlist;
for (int i = 0; i < playlists.count(); i++) {
if (playlists.at(i).toElement().attribute(QStringLiteral("id")) == pCore->binController()->binPlaylistId()) {
if (playlists.at(i).toElement().attribute(QStringLiteral("id")) == BinPlaylist::binPlaylistId) {
playlist = playlists.at(i).toElement();
break;
}
......@@ -1759,6 +1760,17 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
}
}
}
if (version < 0.98) {
// rename main bin playlist
QDomNodeList playlists = m_doc.elementsByTagName(QStringLiteral("playlist"));
QDomElement playlist;
for (int i = 0; i < playlists.count(); i++) {
if (playlists.at(i).toElement().attribute(QStringLiteral("id")) == QLatin1String("main bin")) {
playlists.at(i).toElement().setAttribute(QStringLiteral("id"), BinPlaylist::binPlaylistId);
break;
}
}
}
m_modified = true;
return true;
......
......@@ -20,6 +20,7 @@
#include "kdenlivedoc.h"
#include "bin/bin.h"
#include "bin/bincommands.h"
#include "bin/binplaylist.hpp"
#include "bin/clipcreator.hpp"
#include "bin/model/markerlistmodel.hpp"
#include "bin/projectclip.h"
......@@ -70,7 +71,7 @@
#include <xlocale.h>
#endif
const double DOCUMENTVERSION = 0.97;
const double DOCUMENTVERSION = 0.98;
KdenliveDoc::KdenliveDoc(const QUrl &url, const QString &projectFolder, QUndoGroup *undoGroup, const QString &profileName,
const QMap<QString, QString> &properties, const QMap<QString, QString> &metadata, const QPoint &tracks, bool *openBackup,
......@@ -487,7 +488,7 @@ QDomDocument KdenliveDoc::xmlSceneList(const QString &scene)
QDomNodeList pls = mlt.elementsByTagName(QStringLiteral("playlist"));
QDomElement mainPlaylist;
for (int i = 0; i < pls.count(); ++i) {
if (pls.at(i).toElement().attribute(QStringLiteral("id")) == pCore->binController()->binPlaylistId()) {
if (pls.at(i).toElement().attribute(QStringLiteral("id")) == BinPlaylist::binPlaylistId) {
mainPlaylist = pls.at(i).toElement();
break;
}
......
......@@ -25,8 +25,6 @@
#include "core.h"
#include "kdenlivesettings.h"
static const char *kPlaylistTrackId = "main bin";
BinController::BinController(const QString &profileName)
: QObject()
{
......@@ -89,11 +87,6 @@ void BinController::slotStoreFolder(const QString &folderId, const QString &pare
}
}
const QString BinController::binPlaylistId()
{
return kPlaylistTrackId;
}
int BinController::clipCount() const
{
return m_clipList.size();
......
......@@ -62,8 +62,6 @@ public:
* */
void loadExtraProducer(const QString &id, Mlt::Producer *prod);
/** @brief Returns the name MLT will use to store our bin's playlist */
static const QString binPlaylistId();
/** @brief Clear the bin's playlist */
void destroyBin();
......
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