Fix DVD Wizard crash on chapters

Fixes #379
parent 6fa5116d
......@@ -162,7 +162,7 @@ void DvdWizardChapters::createMonitor(DVDFORMAT format)
if (m_monitor == nullptr) {
// TODO: allow monitor with different profile for DVD
QString profile = DvdWizardVob::getDvdProfile(format);
m_monitor = new Monitor(Kdenlive::DvdMonitor, m_manager /*, profile*/, this);
m_monitor = new Monitor(Kdenlive::DvdMonitor, m_manager, this);
m_monitor->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
m_view.video_frame->layout()->addWidget(m_monitor);
m_manager->appendMonitor(m_monitor);
......
......@@ -870,6 +870,28 @@ static void onThreadStopped(mlt_properties owner, GLWidget *self)
self->stopGlsl();
}
int GLWidget::setProducer(const QString &file)
{
if (m_producer) {
m_producer.reset();
}
qDebug()<<"==== OPENING PROIDUCER FILE: "<<file;
m_producer = std::make_shared<Mlt::Producer>(new Mlt::Producer(pCore->getCurrentProfile()->profile(), nullptr, file.toUtf8().constData()));
if (m_consumer) {
m_consumer->stop();
if (!m_consumer->is_stopped()) {
m_consumer->stop();
}
}
int error = reconfigure();
if (error == 0) {
// The profile display aspect ratio may have changed.
resizeGL(width(), height());
startConsumer();
}
return error;
}
int GLWidget::setProducer(const std::shared_ptr<Mlt::Producer> &producer, bool isActive, int position)
{
int error = 0;
......
......@@ -148,6 +148,7 @@ protected:
void wheelEvent(QWheelEvent *event) override;
/** @brief Update producer, should ONLY be called from monitor */
int setProducer(const std::shared_ptr<Mlt::Producer> &producer, bool isActive, int position = -1);
int setProducer(const QString &file);
QString frameToTime(int frames) const;
public slots:
......
......@@ -143,7 +143,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
, m_loopClipTransition(true)
, m_editMarker(nullptr)
, m_forceSizeFactor(0)
, m_offset(id == Kdenlive::ClipMonitor ? 0 : TimelineModel::seekDuration)
, m_offset(id == Kdenlive::ProjectMonitor ? TimelineModel::seekDuration : 0)
, m_lastMonitorSceneType(MonitorSceneDefault)
{
auto *layout = new QVBoxLayout;
......@@ -379,12 +379,12 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
connect(this, &Monitor::scopesClear, m_glMonitor, &GLWidget::releaseAnalyse, Qt::DirectConnection);
connect(m_glMonitor, &GLWidget::analyseFrame, this, &Monitor::frameUpdated);
if (id != Kdenlive::ClipMonitor) {
if (id == Kdenlive::ProjectMonitor) {
// TODO: reimplement
// connect(render, &Render::durationChanged, this, &Monitor::durationChanged);
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::saveZone, this, &Monitor::zoneUpdated);
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::saveZoneWithUndo, this, &Monitor::zoneUpdatedWithUndo);
} else {
} else if (id == Kdenlive::ClipMonitor) {
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::saveZone, this, &Monitor::updateClipZone);
}
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::triggerAction, pCore.get(), &Core::triggerAction);
......@@ -1463,18 +1463,11 @@ const QString Monitor::activeClipId()
void Monitor::slotOpenDvdFile(const QString &file)
{
// TODO
Q_UNUSED(file)
m_glMonitor->initializeGL();
m_glMonitor->setProducer(file);
// render->loadUrl(file);
}
void Monitor::slotSaveZone()
{
// TODO? or deprecate
// render->saveZone(pCore->currentDoc()->projectDataFolder(), m_ruler->zone());
}
void Monitor::setCustomProfile(const QString &profile, const Timecode &tc)
{
// TODO or deprecate
......@@ -1923,7 +1916,12 @@ QSize Monitor::profileSize() const
void Monitor::loadQmlScene(MonitorSceneType type, QVariant sceneData)
{
if (m_id == Kdenlive::DvdMonitor || (type == m_qmlManager->sceneType() && sceneData.isNull())) {
if (m_id == Kdenlive::DvdMonitor) {
m_qmlManager->setScene(m_id, MonitorSceneDefault, pCore->getCurrentFrameSize(), pCore->getCurrentDar(), m_glMonitor->displayRect(), m_glMonitor->zoom(), m_timePos->maximum());
m_qmlManager->setProperty(QStringLiteral("fps"), QString::number(pCore->getCurrentFps(), 'g', 2));
return;
}
if (type == m_qmlManager->sceneType() && sceneData.isNull()) {
return;
}
bool sceneWithEdit = type == MonitorSceneGeometry || type == MonitorSceneCorners || type == MonitorSceneRoto;
......
......@@ -234,7 +234,6 @@ private:
private slots:
void slotSetThumbFrame();
void slotSaveZone();
void slotSeek();
void updateClipZone(const QPoint zone);
void slotGoToMarker(QAction *action);
......
......@@ -49,9 +49,9 @@ void QmlManager::setScene(Kdenlive::MonitorId id, MonitorSceneType type, QSize p
// Scene type already active
return;
}
if (id == Kdenlive::DvdMonitor) {
/*if (id == Kdenlive::DvdMonitor) {
return;
}
}*/
m_sceneType = type;
QQuickItem *root = nullptr;
m_view->rootContext()->setContextProperty("fixedFont", QFontDatabase::systemFont(QFontDatabase::FixedFont));
......@@ -115,7 +115,7 @@ void QmlManager::setScene(Kdenlive::MonitorId id, MonitorSceneType type, QSize p
break;
default:
m_view->setSource(
QUrl(id == Kdenlive::ClipMonitor ? QStringLiteral("qrc:/qml/kdenliveclipmonitor.qml") : QStringLiteral("qrc:/qml/kdenlivemonitor.qml")));
QUrl(id == Kdenlive::ClipMonitor || id == Kdenlive::DvdMonitor ? QStringLiteral("qrc:/qml/kdenliveclipmonitor.qml") : QStringLiteral("qrc:/qml/kdenlivemonitor.qml")));
root = m_view->rootObject();
root->setProperty("profile", QPoint(profile.width(), profile.height()));
root->setProperty("scalex", scalex);
......
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