Don't crash when wrong sdl driver was selected by user (needs MLT patch):

http://www.kdenlive.org/mantis/view.php?id=971

svn path=/trunk/kdenlive/; revision=3687
parent 295ec990
......@@ -239,13 +239,17 @@ KdenliveDoc::~KdenliveDoc()
}
}
void KdenliveDoc::setSceneList()
int KdenliveDoc::setSceneList()
{
m_render->setSceneList(m_document.toString(), m_documentProperties.value("position").toInt());
if (m_render->setSceneList(m_document.toString(), m_documentProperties.value("position").toInt()) == -1) {
// INVALID MLT Consumer, something is wrong
return -1;
}
m_documentProperties.remove("position");
// m_document xml is now useless, clear it
m_document.clear();
checkProjectClips();
return 0;
}
QDomDocument KdenliveDoc::createEmptyDocument(const int videotracks, const int audiotracks)
......@@ -674,45 +678,6 @@ void KdenliveDoc::checkProjectClips()
kDebug() << "+++++++++++++ + + + + CHK PCLIPS";
if (m_render == NULL) return;
m_clipManager->resetProducersList(m_render->producersList());
return;
// Useless now...
QList <Mlt::Producer *> prods = m_render->producersList();
QString id ;
QString prodId ;
QString prodTrack ;
for (int i = 0; i < prods.count(); i++) {
id = prods.at(i)->get("id");
prodId = id.section('_', 0, 0);
prodTrack = id.section('_', 1, 1);
DocClipBase *clip = m_clipManager->getClipById(prodId);
if (clip) clip->setProducer(prods.at(i));
if (clip && clip->clipType() == TEXT && !QFile::exists(clip->fileURL().path())) {
// regenerate text clip image if required
//kDebug() << "// TITLE: " << clip->getProperty("titlename") << " Preview file: " << clip->getProperty("resource") << " DOES NOT EXIST";
QString titlename = clip->getProperty("name");
QString titleresource;
if (titlename.isEmpty()) {
QStringList titleInfo = TitleWidget::getFreeTitleInfo(projectFolder());
titlename = titleInfo.at(0);
titleresource = titleInfo.at(1);
clip->setProperty("name", titlename);
kDebug() << "// New title set to: " << titlename;
} else {
titleresource = TitleWidget::getFreeTitleInfo(projectFolder()).at(1);
//titleresource = TitleWidget::getTitleResourceFromName(projectFolder(), titlename);
}
TitleWidget *dia_ui = new TitleWidget(KUrl(), KUrl(titleresource).directory(), m_render, kapp->activeWindow());
QDomDocument doc;
doc.setContent(clip->getProperty("xmldata"));
dia_ui->setXml(doc);
QImage pix = dia_ui->renderedPixmap();
pix.save(titleresource);
clip->setProperty("resource", titleresource);
delete dia_ui;
clip->producer()->set("force_reload", 1);
}
}
}
void KdenliveDoc::updatePreviewSettings()
......
......@@ -110,7 +110,7 @@ Q_OBJECT public:
QString getLadspaFile() const;
void setZone(int start, int end);
QPoint zone() const;
void setSceneList();
int setSceneList();
void updatePreviewSettings();
bool isTrackLocked(int ix) const;
void setDocumentProperty(const QString &name, const QString &value);
......
......@@ -314,7 +314,14 @@ void KdenliveSettingsDialog::showPage(int page, int option)
case 5:
setCurrentPage(m_page5);
break;
case 6:
setCurrentPage(m_page6);
break;
case 7:
setCurrentPage(m_page7);
break;
default:
setCurrentPage(m_page1);
}
}
......
......@@ -1237,6 +1237,7 @@ void MainWindow::slotRunWizard()
void MainWindow::newFile(bool showProjectSettings)
{
if (!m_timelineArea->isEnabled()) return;
QString profileName;
KUrl projectFolder;
QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
......@@ -1259,8 +1260,17 @@ void MainWindow::newFile(bool showProjectSettings)
}
KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
TrackView *trackView = new TrackView(doc, this);
bool ok;
TrackView *trackView = new TrackView(doc, &ok, this);
m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
if (!ok) {
// MLT is broken
m_timelineArea->setEnabled(false);
m_projectList->setEnabled(false);
m_monitorManager->slotBlockMonitors();
slotPreferences(6);
return;
}
if (m_timelineArea->count() == 1) {
connectDocumentInfo(doc);
connectDocument(trackView, doc);
......@@ -1270,7 +1280,7 @@ void MainWindow::newFile(bool showProjectSettings)
void MainWindow::activateDocument()
{
if (m_timelineArea->currentWidget() == NULL) return;
if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
KdenliveDoc *currentDoc = currentTab->document();
connectDocumentInfo(currentDoc);
......@@ -1436,6 +1446,7 @@ void MainWindow::openFile(const KUrl &url)
void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
{
if (!m_timelineArea->isEnabled()) return;
KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
if (stale == NULL) {
stale = new KAutoSaveFile(url, doc);
......@@ -1447,8 +1458,16 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
stale->setParent(doc);
}
connectDocumentInfo(doc);
TrackView *trackView = new TrackView(doc, this);
bool ok;
TrackView *trackView = new TrackView(doc, &ok, this);
m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
if (!ok) {
m_timelineArea->setEnabled(false);
m_projectList->setEnabled(false);
m_monitorManager->slotBlockMonitors();
slotPreferences(6);
return;
}
m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
trackView->setDuration(trackView->duration());
trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
......
......@@ -130,6 +130,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent) :
connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int)));
connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
connect(render, SIGNAL(blockMonitors()), this, SIGNAL(blockMonitors()));
//render->createVideoXWindow(m_ui.video_frame->winId(), -1);
......@@ -694,7 +695,10 @@ void Monitor::slotSetXml(DocClipBase *clip, const int position)
}
if (clip != m_currentClip) {
m_currentClip = clip;
render->setProducer(clip->producer(), position);
if (render->setProducer(clip->producer(), position) == -1) {
// MLT CONSUMER is broken
emit blockMonitors();
}
m_position = position;
} else if (position != -1) render->seek(GenTime(position, render->fps()));
}
......
......@@ -163,6 +163,7 @@ signals:
void adjustMonitorSize();
void zoneUpdated(QPoint);
void saveZone(Render *, QPoint);
void blockMonitors();
};
#endif
......@@ -30,7 +30,8 @@
MonitorManager::MonitorManager(QWidget *parent) :
QObject(parent),
m_clipMonitor(NULL),
m_projectMonitor(NULL)
m_projectMonitor(NULL),
m_blocked(false)
{
}
......@@ -43,10 +44,13 @@ void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor)
{
m_clipMonitor = clipMonitor;
m_projectMonitor = projectMonitor;
connect(m_clipMonitor, SIGNAL(blockMonitors()), this, SLOT(slotBlockMonitors()));
connect(m_projectMonitor, SIGNAL(blockMonitors()), this, SLOT(slotBlockMonitors()));
}
void MonitorManager::activateMonitor(QString name)
{
if (m_blocked) return;
if (m_activeMonitor == name) return;
if (name == "clip") {
m_projectMonitor->stop();
......@@ -63,6 +67,7 @@ void MonitorManager::activateMonitor(QString name)
void MonitorManager::switchMonitors()
{
if (m_blocked) return;
if (m_clipMonitor->isActive()) {
m_clipMonitor->stop();
m_projectMonitor->start();
......@@ -79,6 +84,7 @@ void MonitorManager::switchMonitors()
void MonitorManager::stopActiveMonitor()
{
if (m_blocked) return;
if (m_clipMonitor->isActive()) m_clipMonitor->pause();
else m_projectMonitor->pause();
}
......@@ -151,12 +157,14 @@ void MonitorManager::slotEnd()
void MonitorManager::resetProfiles(Timecode tc)
{
if (m_blocked) return;
m_timecode = tc;
QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
}
void MonitorManager::slotResetProfiles()
{
if (m_blocked) return;
if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
activateMonitor("clip");
m_clipMonitor->resetProfile();
......@@ -165,4 +173,17 @@ void MonitorManager::slotResetProfiles()
//m_projectMonitor->refreshMonitor(true);
}
void MonitorManager::slotBlockMonitors()
{
m_blocked = true;
if (m_clipMonitor) {
m_clipMonitor->blockSignals(true);
m_clipMonitor->setEnabled(false);
}
if (m_projectMonitor) {
m_projectMonitor->blockSignals(true);
m_projectMonitor->setEnabled(false);
}
}
#include "monitormanager.moc"
......@@ -52,12 +52,14 @@ public slots:
void slotStart();
void slotEnd();
void slotResetProfiles();
void slotBlockMonitors();
private:
Monitor *m_clipMonitor;
Monitor *m_projectMonitor;
QString m_activeMonitor;
Timecode m_timecode;
bool m_blocked;
signals:
void raiseClipMonitor(bool);
......
......@@ -764,13 +764,13 @@ void Render::initSceneList()
/** Create the producer from the MLT XML QDomDocument */
void Render::setProducer(Mlt::Producer *producer, int position)
int Render::setProducer(Mlt::Producer *producer, int position)
{
if (m_winid == -1) return;
if (m_winid == -1) return -1;
if (m_mltConsumer) {
m_mltConsumer->stop();
} else return;
} else return -1;
m_mltConsumer->purge();
......@@ -791,27 +791,29 @@ void Render::setProducer(Mlt::Producer *producer, int position)
if (!m_mltProducer || !m_mltProducer->is_valid()) kDebug() << " WARNING - - - - -INVALID PLAYLIST: ";
m_fps = m_mltProducer->get_fps();
connectPlaylist();
int error = connectPlaylist();
if (position != -1) {
m_mltProducer->seek(position);
emit rendererPosition(position);
}
m_isBlocked = false;
return error;
}
/** Create the producer from the MLT XML QDomDocument */
void Render::setSceneList(QDomDocument list, int position)
int Render::setSceneList(QDomDocument list, int position)
{
setSceneList(list.toString(), position);
return setSceneList(list.toString(), position);
}
/** Create the producer from the MLT XML QDomDocument */
void Render::setSceneList(QString playlist, int position)
int Render::setSceneList(QString playlist, int position)
{
if (m_winid == -1) return;
if (m_winid == -1) return -1;
m_isBlocked = true;
int error;
qDeleteAll(m_slowmotionProducers.values());
m_slowmotionProducers.clear();
......@@ -820,7 +822,7 @@ void Render::setSceneList(QString playlist, int position)
if (m_mltConsumer == NULL) {
kWarning() << "/////// ERROR, TRYING TO USE NULL MLT CONSUMER";
m_isBlocked = false;
return;
return -1;
}
if (!m_mltConsumer->is_stopped()) {
......@@ -879,12 +881,13 @@ void Render::setSceneList(QString playlist, int position)
}
kDebug() << "// NEW SCENE LIST DURATION SET TO: " << m_mltProducer->get_playtime();
connectPlaylist();
error = connectPlaylist();
fillSlowMotionProducers();
m_isBlocked = false;
blockSignals(false);
emit refreshDocumentProducers();
return error;
//kDebug()<<"// SETSCN LST, POS: "<<position;
//if (position != 0) emit rendererPosition(position);
}
......@@ -969,24 +972,23 @@ double Render::fps() const
return m_fps;
}
void Render::connectPlaylist()
int Render::connectPlaylist()
{
if (!m_mltConsumer) return;
if (!m_mltConsumer) return -1;
//m_mltConsumer->set("refresh", "0");
m_mltConsumer->connect(*m_mltProducer);
m_mltProducer->set_speed(0);
m_mltConsumer->start();
if (m_mltConsumer->start() == -1) {
// ARGH CONSUMER BROKEN!!!!
KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
emit blockMonitors();
delete m_mltProducer;
m_mltProducer = NULL;
return -1;
}
emit durationChanged(m_mltProducer->get_playtime());
return 0;
//refresh();
/*
if (m_mltConsumer->start() == -1) {
KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
delete m_mltConsumer;
m_mltConsumer = NULL;
}
else {
refresh();
}*/
}
void Render::refreshDisplay()
......@@ -1045,14 +1047,13 @@ void Render::start()
kDebug() << "----- BROKEN MONITOR: " << m_name << ", RESTART";
return;
}
if (m_mltConsumer && m_mltConsumer->is_stopped()) {
kDebug() << "----- MONITOR: " << m_name << " WAS STOPPED";
if (m_mltConsumer->start() == -1) {
KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
delete m_mltConsumer;
m_mltConsumer = NULL;
return;
emit blockMonitors();
delete m_mltProducer;
m_mltProducer = NULL;
} else {
kDebug() << "----- MONITOR: " << m_name << " REFRESH";
m_isBlocked = false;
......@@ -1081,6 +1082,7 @@ void Render::clear()
void Render::stop()
{
if (m_mltProducer == NULL) return;
if (m_mltConsumer && !m_mltConsumer->is_stopped()) {
kDebug() << "///////////// RENDER STOPPED: " << m_name;
m_isBlocked = true;
......@@ -1254,7 +1256,12 @@ void Render::setDropFrames(bool show)
if (show == false) dropFrames = 0;
m_mltConsumer->stop();
m_mltConsumer->set("play.real_time", dropFrames);
m_mltConsumer->start();
if (m_mltConsumer->start() == -1) {
emit blockMonitors();
delete m_mltProducer;
m_mltProducer = NULL;
}
}
}
......@@ -2913,6 +2920,7 @@ void Render::mltSavePlaylist()
QList <Mlt::Producer *> Render::producersList()
{
QList <Mlt::Producer *> prods;
if (m_mltProducer == NULL) return prods;
Mlt::Service service(m_mltProducer->parent().get_service());
if (service.type() != tractor_type) return prods;
Mlt::Tractor tractor(service);
......@@ -2943,6 +2951,7 @@ QList <Mlt::Producer *> Render::producersList()
void Render::fillSlowMotionProducers()
{
if (m_mltProducer == NULL) return;
Mlt::Service service(m_mltProducer->parent().get_service());
if (service.type() != tractor_type) return;
......
......@@ -91,9 +91,9 @@ Q_OBJECT public:
/** Wraps the VEML command of the same name. Sets the current scene list to
be list. */
void setSceneList(QDomDocument list, int position = 0);
void setSceneList(QString playlist, int position = 0);
void setProducer(Mlt::Producer *producer, int position);
int setSceneList(QDomDocument list, int position = 0);
int setSceneList(QString playlist, int position = 0);
int setProducer(Mlt::Producer *producer, int position);
const QString sceneList();
bool saveSceneList(QString path, QDomElement kdenliveData = QDomElement());
......@@ -232,7 +232,7 @@ private slots: // Private slots
/** refresh monitor display */
void refresh();
void slotOsdTimeout();
void connectPlaylist();
int connectPlaylist();
//void initSceneList();
signals: // Signals
......@@ -259,6 +259,7 @@ signals: // Signals
void rendererStopped(int);
void removeInvalidClip(const QString &, bool replaceProducer);
void refreshDocumentProducers();
void blockMonitors();
public slots: // Public slots
/** Start Consumer */
......
......@@ -36,7 +36,7 @@
#include <QScrollBar>
TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) :
TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
QWidget(parent),
m_scale(1.0),
m_projectTracks(0),
......@@ -103,7 +103,9 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) :
connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
parseDocument(m_doc->toXml());
m_doc->setSceneList();
int error = m_doc->setSceneList();
if (error == -1) *ok = false;
else *ok = true;
connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
......
......@@ -45,7 +45,7 @@ class TrackView : public QWidget
Q_OBJECT
public:
explicit TrackView(KdenliveDoc *doc, QWidget *parent = 0);
explicit TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent = 0);
virtual ~ TrackView();
void setEditMode(const QString & editMode);
const QString & editMode() const;
......
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