Fix connection of main bin playlist in new documents

parent 06edd57a
......@@ -197,10 +197,10 @@ void BinController::createIfNeeded(Mlt::Profile *profile)
m_binPlaylist->set("id", kPlaylistTrackId);
}
void BinController::loadBinPlaylist(Mlt::Tractor *tractor)
void BinController::loadBinPlaylist(Mlt::Tractor *documentTractor, Mlt::Tractor *modelTractor)
{
destroyBin();
Mlt::Properties retainList((mlt_properties)tractor->get_data("xml_retain"));
Mlt::Properties retainList((mlt_properties)documentTractor->get_data("xml_retain"));
qDebug() << "Loading bin playlist...";
if (retainList.is_valid() && (retainList.get_data(binPlaylistId().toUtf8().constData()) != nullptr)) {
Mlt::Playlist playlist((mlt_playlist)retainList.get_data(binPlaylistId().toUtf8().constData()));
......@@ -214,11 +214,11 @@ void BinController::loadBinPlaylist(Mlt::Tractor *tractor)
// If no Playlist found, create new one
if (!m_binPlaylist) {
qDebug() << "no playlist valid, creating";
m_binPlaylist.reset(new Mlt::Playlist(*tractor->profile()));
m_binPlaylist.reset(new Mlt::Playlist(*modelTractor->profile()));
m_binPlaylist->set("id", kPlaylistTrackId);
}
QString retain = QStringLiteral("xml_retain %1").arg(binPlaylistId());
tractor->set(retain.toUtf8().constData(), m_binPlaylist->get_service(), 0);
modelTractor->set(retain.toUtf8().constData(), m_binPlaylist->get_service(), 0);
}
void BinController::slotStoreFolder(const QString &folderId, const QString &parentId, const QString &oldParentId, const QString &folderName)
......
......@@ -80,8 +80,8 @@ public:
/** @brief Clear the bin's playlist */
void destroyBin();
/** @brief Load the Bin's main playlist from an existing tractor */
void loadBinPlaylist(Mlt::Tractor *tractor);
/** @brief Load the Bin's main playlist from an existing tractor, and pass it to the model */
void loadBinPlaylist(Mlt::Tractor *documentTractor, Mlt::Tractor *modelTractor);
/** @brief Initialize the bin's playlist from MLT's data
* @param playlist The MLT playlist containing our bin's clips
......
......@@ -862,8 +862,6 @@ void ProjectManager::updateTimeline()
QScopedPointer<Mlt::Producer> xmlProd(new Mlt::Producer(pCore->getCurrentProfile()->profile(), "xml-string", m_project->getProjectXml().constData()));
Mlt::Service s(*xmlProd);
Mlt::Tractor tractor(s);
pCore->binController()->loadBinPlaylist(&tractor);
m_mainTimelineModel = TimelineItemModel::construct(&pCore->getCurrentProfile()->profile(), m_project->getGuideModel(), m_project->commandStack());
constructTimelineFromMelt(m_mainTimelineModel, tractor);
const QStringList ids = pCore->binController()->getClipIds();
......
......@@ -27,6 +27,7 @@
#include "../undohelper.hpp"
#include "core.h"
#include "bin/bin.h"
#include "mltcontroller/bincontroller.h"
#include <QDebug>
#include <QSet>
#include <mlt++/MltPlaylist.h>
......@@ -42,7 +43,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
Fun redo = []() { return true; };
// First, we destruct the previous tracks
timeline->requestReset(undo, redo);
pCore->binController()->loadBinPlaylist(&tractor, timeline->tractor());
QSet<QString> reserved_names{QLatin1String("playlistmain"), QLatin1String("timeline_preview"), QLatin1String("overlay_track"),
QLatin1String("black_track")};
......
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