]> git.sesse.net Git - kdenlive/commitdiff
Fix crash and corruption caused by bad index in effects
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Feb 2010 22:28:02 +0000 (22:28 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Feb 2010 22:28:02 +0000 (22:28 +0000)
svn path=/trunk/kdenlive/; revision=4268

src/effectslist.cpp
src/trackview.cpp

index 1b400ae64020b3ba5fd0f692ea9cbc9cd50208cb..bd71efb077e1104547c87b2bbf6b87de3fc5ac8a 100644 (file)
@@ -243,27 +243,28 @@ bool EffectsList::isEmpty() const
 const QDomElement EffectsList::at(int ix) const
 {
     QDomNodeList effects = m_baseElement.childNodes();
-    if (ix >= effects.count()) return QDomElement();
+    if (ix < 0 || ix >= effects.count()) return QDomElement();
     return effects.at(ix).toElement();
 }
 
 void EffectsList::removeAt(int ix)
 {
     QDomNodeList effects = m_baseElement.childNodes();
-    if (ix >= effects.count()) return;
+    if (ix < 0 || ix >= effects.count()) return;
     m_baseElement.removeChild(effects.at(ix));
 }
 
 QDomElement EffectsList::item(int ix)
 {
     QDomNodeList effects = m_baseElement.childNodes();
-    if (ix >= effects.count()) return QDomElement();
+    if (ix < 0 || ix >= effects.count()) return QDomElement();
     return effects.at(ix).toElement();
 }
 
 void EffectsList::insert(int ix, QDomElement effect)
 {
     QDomNodeList effects = m_baseElement.childNodes();
+    if (ix < 0) ix = 0;
     if (ix >= effects.count()) m_baseElement.appendChild(importNode(effect, true));
     else m_baseElement.insertBefore(importNode(effect, true), effects.at(ix));
 }
@@ -271,6 +272,7 @@ void EffectsList::insert(int ix, QDomElement effect)
 void EffectsList::replace(int ix, QDomElement effect)
 {
     QDomNodeList effects = m_baseElement.childNodes();
+    if (ix < 0) ix = 0;
     if (ix < effects.count()) m_baseElement.removeChild(effects.at(ix));
     if (ix == effects.count()) m_baseElement.appendChild(importNode(effect, true));
     else m_baseElement.insertBefore(importNode(effect, true), effects.at(ix));
index 9b95d97032e77d223bb226ce58a809898e447643..7052392d7b74ed8f8b4d0ef6eddf43f273efa718 100644 (file)
@@ -650,7 +650,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                         // add effect to clip
                         QString effecttag;
                         QString effectid;
-                        QString effectindex;
+                        QString effectindex = QString::number(ix + 1);
                         QString ladspaEffectFile;
                         // Get effect tag & index
                         for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
@@ -661,7 +661,8 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                             } else if (effectparam.attribute("name") == "kdenlive_id") {
                                 effectid = effectparam.text();
                             } else if (effectparam.attribute("name") == "kdenlive_ix") {
-                                effectindex = effectparam.text();
+                                // Fix effects index
+                                effectparam.firstChild().setNodeValue(effectindex);
                             } else if (effectparam.attribute("name") == "src") {
                                 ladspaEffectFile = effectparam.text();
                                 if (!QFile::exists(ladspaEffectFile)) {
@@ -814,7 +815,6 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                                 currenteffect.setAttribute("src", ladspaEffectFile);
                             }
                             item->addEffect(currenteffect, false);
-                            item->effectsCounter();
                         }
                     }
                 }