Commit 5c88cc2b authored by Nicolas Carion's avatar Nicolas Carion

Create the Mlt connection inside core init

parent 74cc4285
......@@ -12,6 +12,7 @@ the Free Software Foundation, either version 3 of the License, or
#include "mainwindow.h"
#include "project/projectmanager.h"
#include "monitor/monitormanager.h"
#include "mltconnection.h"
#include "mltcontroller/bincontroller.h"
#include "mltcontroller/producerqueue.h"
#include "bin/bin.h"
......@@ -66,7 +67,7 @@ void Core::build(const QString &MltPath, const QUrl &Url, const QString &clipsTo
qRegisterMetaType<requestClipInfo> ("requestClipInfo");
qRegisterMetaType<MltVideoProfile> ("MltVideoProfile");
m_self->initialize();
m_self->initialize(MltPath);
m_self->m_mainWindow->init(MltPath, Url, clipsToLoad);
if (qApp->isSessionRestored()) {
//NOTE: we are restoring only one window, because Kdenlive only uses one MainWindow
......@@ -75,8 +76,9 @@ void Core::build(const QString &MltPath, const QUrl &Url, const QString &clipsTo
m_self->m_mainWindow->show();
}
void Core::initialize()
void Core::initialize(const QString &mltPath)
{
m_mltConnection = std::make_shared<MltConnection>(mltPath);
m_mainWindow = new MainWindow();
m_projectManager = new ProjectManager(this);
m_binWidget = new Bin();
......
......@@ -11,6 +11,7 @@ the Free Software Foundation, either version 3 of the License, or
#ifndef CORE_H
#define CORE_H
#include <memory>
#include <QTabWidget>
#include <QObject>
#include <QUrl>
......@@ -23,6 +24,7 @@ class BinController;
class Bin;
class LibraryWidget;
class ProducerQueue;
class MltConnection;
#define EXIT_RESTART (42)
#define pCore Core::self()
......@@ -61,9 +63,6 @@ public:
/** @brief Returns a pointer to the singleton object. */
static Core *self();
/** @brief Builds all necessary parts. */
void initialize();
/** @brief Returns a pointer to the main window. */
MainWindow *window();
......@@ -88,6 +87,9 @@ private:
explicit Core();
static Core *m_self;
/** @brief Builds all necessary parts. */
void initialize(const QString &mltPath);
/** @brief Makes sure Qt's locale and system locale settings match. */
void initLocale();
......@@ -100,6 +102,8 @@ private:
LibraryWidget *m_library;
QTabWidget *m_timelineTab;
std::shared_ptr<MltConnection> m_mltConnection;
signals:
void coreIsReady();
void updateLibraryPath();
......
......@@ -217,7 +217,6 @@ void MainWindow::init(const QString &MltPath, const QUrl &Url, const QString &cl
//QIcon::setThemeSearchPaths(QStringList() <<QStringLiteral(":/icons/"));
new RenderingAdaptor(this);
MltConnection::locateMeltAndProfilesPath(MltPath);
QString defaultProfile = KdenliveSettings::default_profile();
KdenliveSettings::setCurrent_profile(defaultProfile.isEmpty() ? ProjectManager::getDefaultProjectFormat() : defaultProfile);
m_commandStack = new QUndoGroup(this);
......
......@@ -22,10 +22,15 @@ the Free Software Foundation, either version 3 of the License, or
#include <QStandardPaths>
#include "kdenlive_debug.h"
MltConnection::MltConnection(QObject *parent) :
QObject(parent)
int MltConnection::instanceCounter = 0;
MltConnection::MltConnection(const QString &mltPath)
{
MltConnection::instanceCounter++;
if (MltConnection::instanceCounter > 1) {
qDebug() << "DEBUG: Warning : trying to open a second mlt connection";
return;
}
locateMeltAndProfilesPath(mltPath);
}
void MltConnection::locateMeltAndProfilesPath(const QString &mltPath)
......
......@@ -17,15 +17,18 @@ the Free Software Foundation, either version 3 of the License, or
* @class MltConnection
* @brief Initializes MLT and provides access to its API
*
* WIP…
*/
class MltConnection : public QObject
class MltConnection
{
Q_OBJECT
public:
explicit MltConnection(QObject *parent = nullptr);
/** @brief Open connection to the MLT framework
This constructor should be called only once
*/
MltConnection(const QString &mltPath);
protected:
/** @brief Locates the MLT environment.
* @param mltPath (optional) path to MLT environment
......@@ -33,7 +36,9 @@ public:
* It tries to set the paths of the MLT profiles and renderer, using
* mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
* user. It doesn't fill any list of profiles, while its name suggests so. */
static void locateMeltAndProfilesPath(const QString &mltPath = QString());
void locateMeltAndProfilesPath(const QString &mltPath = QString());
static int instanceCounter;
};
#endif
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