]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Don't crash when wrong sdl driver was selected by user (needs MLT patch):
[kdenlive] / src / mainwindow.cpp
index ef285aa56a2e89a857a11d2ffc31cd033b5a3a22..cba1a86369f3aa1deb29cd341231c7aac862ab79 100644 (file)
@@ -495,17 +495,19 @@ void MainWindow::generateClip()
     }
 }
 
-void MainWindow::saveProperties(KConfig*)
+void MainWindow::saveProperties(KConfigGroup &config)
 {
     // save properties here,used by session management
     saveFile();
+    KMainWindow::saveProperties(config);
 }
 
 
-void MainWindow::readProperties(KConfig *config)
+void MainWindow::readProperties(const KConfigGroup &config)
 {
     // read properties here,used by session management
-    QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
+    KMainWindow::readProperties(config);
+    QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
     openFile(KUrl(Lastproject));
 }
 
@@ -1235,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());
@@ -1257,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);
@@ -1268,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);
@@ -1434,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);
@@ -1445,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()));
@@ -1610,15 +1631,15 @@ void MainWindow::slotRenderProject()
     if (!m_renderWidget) {
         QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
         m_renderWidget = new RenderWidget(projectfolder, this);
-        connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &)));
+        connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
         connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
         connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
         connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
         if (m_activeDocument) {
             m_renderWidget->setProfile(m_activeDocument->mltProfile());
             m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
-            m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"));
             m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
+            m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
         }
     }
     /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
@@ -1789,7 +1810,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
         m_renderWidget->setProfile(doc->mltProfile());
         m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
         m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
-        m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"));
+        m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
     }
     //doc->setRenderer(m_projectMonitor->render);
     m_commandStack->setActiveStack(doc->commandStack());
@@ -1933,7 +1954,7 @@ void MainWindow::slotAddClipMarker()
         if (m_activeTimeline) {
             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
             if (item) {
-                pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
+                pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
                 clip = item->baseClip();
             }
         }
@@ -1962,7 +1983,7 @@ void MainWindow::slotDeleteClipMarker()
         if (m_activeTimeline) {
             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
             if (item) {
-                pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
+                pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
                 clip = item->baseClip();
             }
         }
@@ -2015,7 +2036,7 @@ void MainWindow::slotEditClipMarker()
         if (m_activeTimeline) {
             ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
             if (item) {
-                pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
+                pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
                 clip = item->baseClip();
             }
         }
@@ -2675,11 +2696,12 @@ void MainWindow::slotTranscodeClip()
     slotTranscode(urls);
 }
 
-void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name)
+void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
 {
     if (m_activeDocument == NULL) return;
     m_activeDocument->setDocumentProperty("renderdestination", dest);
     m_activeDocument->setDocumentProperty("renderprofile", name);
+    m_activeDocument->setDocumentProperty("renderurl", file);
     m_activeDocument->setModified(true);
 }