]> git.sesse.net Git - kdenlive/commitdiff
cleanup & fix crash on project saving with Qt 4.5:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 3 Mar 2009 02:48:13 +0000 (02:48 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 3 Mar 2009 02:48:13 +0000 (02:48 +0000)
http://www.kdenlive.org:80/mantis/view.php?id=687

svn path=/branches/KDE4/; revision=3086

src/customtrackview.cpp
src/docclipbase.cpp
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/monitor.cpp
src/monitor.h
src/renderer.cpp
src/renderer.h

index f5d259a8cf1f729d56100629ba56a0d49eb2c24e..16a167fc7f55f4b582603c91c27c905493a82987 100644 (file)
@@ -2402,13 +2402,12 @@ void CustomTrackView::doChangeClipSpeed(ItemInfo info, const double speed, const
     info.track = m_document->tracksCount() - item->track();
     int endPos = m_document->renderer()->mltChangeClipSpeed(info, speed, oldspeed, baseclip->producer());
     if (endPos >= 0) {
-       item->setSpeed(speed);
-       item->updateRectGeometry();
-       if (item->cropDuration().frames(m_document->fps()) > endPos)
-           item->AbstractClipItem::resizeEnd(info.startPos.frames(m_document->fps()) + endPos, speed);
-       m_document->setModified(true);
-    }
-    else emit displayMessage(i18n("Invalid clip"), ErrorMessage);
+        item->setSpeed(speed);
+        item->updateRectGeometry();
+        if (item->cropDuration().frames(m_document->fps()) > endPos)
+            item->AbstractClipItem::resizeEnd(info.startPos.frames(m_document->fps()) + endPos, speed);
+        m_document->setModified(true);
+    } else emit displayMessage(i18n("Invalid clip"), ErrorMessage);
 }
 
 void CustomTrackView::cutSelectedClips() {
index 3bddb769a2202825b02215f8ebdfe018e57d23bb..321a641d121712f42f2a93da55a0e970814933c4 100644 (file)
@@ -194,7 +194,6 @@ bool DocClipBase::hasFileSize() const {
 // virtual
 QDomElement DocClipBase::toXML() const {
     QDomDocument doc;
-
     QDomElement clip = doc.createElement("producer");
 
     QMapIterator<QString, QString> i(m_properties);
@@ -202,9 +201,9 @@ QDomElement DocClipBase::toXML() const {
         i.next();
         if (!i.value().isEmpty()) clip.setAttribute(i.key(), i.value());
     }
-    //doc.appendChild(clip);
+    doc.appendChild(clip);
     //kDebug()<<"/// CLIP XML: "<<doc.toString();
-    return clip;
+    return doc.documentElement();
 }
 
 DocClipBase *DocClipBase::
index 4f098d2e61e232f62cd7dddfbb61325cdc9b4fd1..20255581c93602f175211b9742e4ad5cafba78d5 100644 (file)
@@ -354,14 +354,14 @@ void KdenliveDoc::slotAutoSave() {
             kDebug() << "ERROR; CANNOT CREATE AUTOSAVE FILE";
         }
         kDebug() << "// AUTOSAVE FILE: " << m_autosave->fileName();
-        QDomDocument doc;
+        QString doc;
         if (KdenliveSettings::dropbframes()) {
             KdenliveSettings::setDropbframes(false);
             m_clipManager->updatePreviewSettings();
-            doc.setContent(m_render->sceneList());
+            doc = m_render->sceneList();
             KdenliveSettings::setDropbframes(true);
             m_clipManager->updatePreviewSettings();
-        } else doc.setContent(m_render->sceneList());
+        } else doc = m_render->sceneList();
         saveSceneList(m_autosave->fileName(), doc);
     }
 }
@@ -917,10 +917,13 @@ QPoint KdenliveDoc::zone() const {
     return QPoint(m_zoneStart, m_zoneEnd);
 }
 
-bool KdenliveDoc::saveSceneList(const QString &path, QDomDocument sceneList) {
+bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene) {
+    QDomDocument sceneList;
+    sceneList.setContent(scene, true);
     QDomNode wes = sceneList.elementsByTagName("westley").at(0);
-
     QDomElement addedXml = sceneList.createElement("kdenlivedoc");
+    wes.appendChild(addedXml);
+
     QDomElement markers = sceneList.createElement("markers");
     addedXml.setAttribute("version", "0.82");
     addedXml.setAttribute("profile", profilePath());
@@ -973,7 +976,6 @@ bool KdenliveDoc::saveSceneList(const QString &path, QDomDocument sceneList) {
     addedXml.appendChild(markers);
     if (!m_guidesXml.isNull()) addedXml.appendChild(sceneList.importNode(m_guidesXml, true));
 
-    wes.appendChild(addedXml);
     //wes.appendChild(doc.importNode(kdenliveData, true));
 
     QFile file(path);
@@ -982,6 +984,7 @@ bool KdenliveDoc::saveSceneList(const QString &path, QDomDocument sceneList) {
         KMessageBox::error(kapp->activeWindow(), i18n("Cannot write to file %1", path));
         return false;
     }
+
     QTextStream out(&file);
     out << sceneList.toString();
     file.close();
@@ -1035,7 +1038,7 @@ void KdenliveDoc::moveProjectData(KUrl url) {
     }
 }
 
-QString KdenliveDoc::profilePath() const {
+const QString &KdenliveDoc::profilePath() const {
     return m_profile.path;
 }
 
@@ -1244,7 +1247,7 @@ bool KdenliveDoc::isModified() const {
     return m_modified;
 }
 
-QString KdenliveDoc::description() const {
+const QString KdenliveDoc::description() const {
     if (m_url.isEmpty())
         return i18n("Untitled") + " / " + m_profile.description;
     else
index c4adb645e03b07a3e35573aa6c48fad725837b52..df9d0a890d665b42601da70a3f3f2820e201e978 100644 (file)
@@ -80,9 +80,9 @@ Q_OBJECT public:
     void deleteProjectClip(QList <QString> ids);
     /** Inform application of the audio thumbnails generation progress */
     void setThumbsProgress(const QString &message, int progress);
-    QString profilePath() const;
+    const QString &profilePath() const;
     MltVideoProfile mltProfile() const;
-    QString description() const;
+    const QString description() const;
     void setUrl(KUrl url);
     void setProfilePath(QString path);
     const QString &getFreeClipId();
@@ -97,7 +97,7 @@ Q_OBJECT public:
     int zoom() const;
     const double dar();
     double projectDuration() const;
-    bool saveSceneList(const QString &path, QDomDocument sceneList);
+    bool saveSceneList(const QString &path, const QString &scene);
     int tracksCount() const;
     TrackInfo trackInfoAt(int ix) const;
     void insertTrack(int ix, TrackInfo type);
index 7147d3b8789430e3207c32018f683d3184e331b6..61023a80177ea047aafbab009b47bbf26988ecbf 100644 (file)
@@ -1181,7 +1181,7 @@ void MainWindow::closeCurrentDocument() {
 }
 
 bool MainWindow::saveFileAs(const QString &outputFileName) {
-    QDomDocument currentSceneList;
+    QString currentSceneList;
     if (KdenliveSettings::dropbframes()) {
         KdenliveSettings::setDropbframes(false);
         m_activeDocument->clipManager()->updatePreviewSettings();
index 0d055d75e0fda93a9604901c1907f937c409db09..eb001c65be51bb76b8dbdc098ec199000bcc9b91 100644 (file)
@@ -654,11 +654,9 @@ void Monitor::saveSceneList(QString path, QDomElement info) {
     render->saveSceneList(path, info);
 }
 
-QDomDocument Monitor::sceneList() {
-    if (render == NULL) return QDomDocument();
-    QDomDocument doc;
-    doc.setContent(render->sceneList());
-    return doc;
+const QString Monitor::sceneList() {
+    if (render == NULL) return QString();
+    return render->sceneList();
 }
 
 
index 87f876c8e1e40eb70abbc91079b7874a79c74c22..b141e7cc68c00e48405529e0d1d94009e0d6782f 100644 (file)
@@ -71,7 +71,7 @@ public:
     bool isActive() const;
     void pause();
     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL);
-    QDomDocument sceneList();
+    const QString sceneList();
     DocClipBase *activeClip();
     GenTime position();
     void checkOverlay();
index df1431154abc1c84e914f97f88773c02f24afc32..a4559e7cbd8b9db7f891528aa9fe47df6b720dd2 100644 (file)
@@ -846,7 +846,7 @@ void Render::setSceneList(QString playlist, int position) {
 }
 
 /** Create the producer from the Westley QDomDocument */
-QString Render::sceneList() {
+const QString Render::sceneList() {
     QString playlist;
     Mlt::Consumer westleyConsumer(*m_mltProfile , "westley:kdenlive_playlist");
     m_mltProducer->optimise();
@@ -1649,13 +1649,13 @@ int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, Mlt
 
     Mlt::Producer clip(trackPlaylist.get_clip(clipIndex));
     if (!clip.is_valid() || clip.is_blank()) {
-       // invalid clip
-       return -1;
+        // invalid clip
+        return -1;
     }
     Mlt::Producer clipparent = clip.parent();
     if (!clipparent.is_valid() || clipparent.is_blank()) {
-       // invalid clip
-       return -1;
+        // invalid clip
+        return -1;
     }
     QString serv = clipparent.get("mlt_service");
     QString id = clipparent.get("id");
index d10b5d3445217c005c426b19b9ff2da8bb750e69..eafd05a076e3b9f2cb8a8af6e1a6e60876392d97 100644 (file)
@@ -91,7 +91,7 @@ Q_OBJECT public:
     void setSceneList(QDomDocument list, int position = 0);
     void setSceneList(QString playlist, int position = 0);
     void setProducer(Mlt::Producer *producer, int position);
-    QString sceneList();
+    const QString sceneList();
     void saveSceneList(QString path, QDomElement kdenliveData = QDomElement());
 
     /** Wraps the VEML command of the same name. Tells the renderer to