]> git.sesse.net Git - kdenlive/blobdiff - src/trackview.cpp
const modifiers are useless on integral return types [PATCH by Ray Lehtiniemi]
[kdenlive] / src / trackview.cpp
index 72cf2823ec818a2f22f0b9796f78697fb7d911e5..c3890f6e0c1f0cd06bf4ae975467ceb0c94f4a19 100644 (file)
@@ -120,7 +120,7 @@ void TrackView::setDuration(int dur) {
 }
 
 void TrackView::parseDocument(QDomDocument doc) {
-    int cursorPos = 0;
+    //int cursorPos = 0;
     m_documentErrors.clear();
     // kDebug() << "//// DOCUMENT: " << doc.toString();
     /*QDomNode props = doc.elementsByTagName("properties").item(0);
@@ -139,7 +139,23 @@ void TrackView::parseDocument(QDomDocument doc) {
     QDomElement p;
 
     int pos = m_projectTracks - 1;
-
+    m_invalidProducers.clear();
+    QDomNodeList producers = doc.elementsByTagName("producer");
+    for (int i = 0; i < producers.count(); i++) {
+        // CHeck for invalid producers
+        QDomNode n = producers.item(i);
+        e = n.toElement();
+        int in = e.attribute("in").toInt();
+        int out = e.attribute("out").toInt();
+        if (in > out || in == out) {
+            // invalid producer, remove it
+            QString id = e.attribute("id");
+            m_invalidProducers.append(id);
+            m_documentErrors.append(i18n("Invalid clip producer %1\n", id));
+            doc.documentElement().removeChild(producers.at(i));
+            i--;
+        }
+    }
 
     for (int i = 0; i < m_projectTracks; i++) {
         e = tracks.item(i).toElement();
@@ -336,11 +352,11 @@ int TrackView::fitZoom() const {
     return i;
 }
 
-const double TrackView::zoomFactor() const {
+double TrackView::zoomFactor() const {
     return m_scale;
 }
 
-const int TrackView::mapLocalToValue(int x) const {
+int TrackView::mapLocalToValue(int x) const {
     return (int)(x * zoomFactor());
 }
 
@@ -374,10 +390,11 @@ void TrackView::slotRebuildTrackHeaders() {
 
 
 int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked) {
-    int trackTop = KdenliveSettings::trackheight() * ix;
     // parse track
     int position = 0;
-    for (QDomNode n = xml.firstChild(); !n.isNull(); n = n.nextSibling()) {
+    QDomNodeList children = xml.childNodes();
+    for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
+        QDomNode n = children.item(nodeindex);
         QDomElement elem = n.toElement();
         if (elem.tagName() == "blank") {
             position += elem.attribute("length").toInt();
@@ -387,8 +404,10 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked) {
             // Found a clip
             int in = elem.attribute("in").toInt();
             int out = elem.attribute("out").toInt();
-            if (in > out || in == out) {
+            if (in > out || in == out || m_invalidProducers.contains(elem.attribute("producer"))) {
                 m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
+                xml.removeChild(children.at(nodeindex));
+                nodeindex--;
                 continue;
             }
             QString idString = elem.attribute("producer");
@@ -461,7 +480,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked) {
                             if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
                                 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND  * * * * * * * * * * *";
                                 // effect is key-framable, read all effects to retrieve keyframes
-                                double factor;
+                                double factor = 0;
                                 QString starttag;
                                 QString endtag;
                                 QDomNodeList params = currenteffect.elementsByTagName("parameter");
@@ -477,8 +496,8 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked) {
                                 QString keyframes;
                                 int effectin = effect.attribute("in").toInt();
                                 int effectout = effect.attribute("out").toInt();
-                                double startvalue;
-                                double endvalue;
+                                double startvalue = 0;
+                                double endvalue = 0;
                                 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
                                     // parse effect parameters
                                     QDomElement effectparam = n3.toElement();