]> git.sesse.net Git - kdenlive/commitdiff
Fix bug in effect deletion with clip groups
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 12 Jun 2009 22:44:01 +0000 (22:44 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 12 Jun 2009 22:44:01 +0000 (22:44 +0000)
svn path=/trunk/kdenlive/; revision=3524

src/clipitem.cpp
src/customtrackview.cpp

index 312886cd5dabe4f118c5d72e9756ad8c87acd79c..ab680d99dd30f79376a28e32c58f159e485ac259 100644 (file)
@@ -309,27 +309,29 @@ void ClipItem::setSelectedEffect(const int ix)
 {
     m_selectedEffect = ix;
     QDomElement effect = effectAt(m_selectedEffect);
-    QDomNodeList params = effect.elementsByTagName("parameter");
-    if (effect.attribute("disabled") != "1")
-        for (int i = 0; i < params.count(); i++) {
-            QDomElement e = params.item(i).toElement();
-            if (!e.isNull() && e.attribute("type") == "keyframe") {
-                m_keyframes.clear();
-                double max = e.attribute("max").toDouble();
-                double min = e.attribute("min").toDouble();
-                m_keyframeFactor = 100.0 / (max - min);
-                m_keyframeDefault = e.attribute("default").toDouble();
-                // parse keyframes
-                const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
-                foreach(const QString &str, keyframes) {
-                    int pos = str.section(':', 0, 0).toInt();
-                    double val = str.section(':', 1, 1).toDouble();
-                    m_keyframes[pos] = val;
+    if (effect.isNull() == false) {
+        QDomNodeList params = effect.elementsByTagName("parameter");
+        if (effect.attribute("disabled") != "1")
+            for (int i = 0; i < params.count(); i++) {
+                QDomElement e = params.item(i).toElement();
+                if (!e.isNull() && e.attribute("type") == "keyframe") {
+                    m_keyframes.clear();
+                    double max = e.attribute("max").toDouble();
+                    double min = e.attribute("min").toDouble();
+                    m_keyframeFactor = 100.0 / (max - min);
+                    m_keyframeDefault = e.attribute("default").toDouble();
+                    // parse keyframes
+                    const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
+                    foreach(const QString &str, keyframes) {
+                        int pos = str.section(':', 0, 0).toInt();
+                        double val = str.section(':', 1, 1).toDouble();
+                        m_keyframes[pos] = val;
+                    }
+                    update();
+                    return;
                 }
-                update();
-                return;
             }
-        }
+    }
     if (!m_keyframes.isEmpty()) {
         m_keyframes.clear();
         update();
@@ -1368,8 +1370,7 @@ EffectsParameterList ClipItem::addEffect(QDomElement effect, bool animate)
         update(r);
     }
     if (m_selectedEffect == -1) {
-        m_selectedEffect = 0;
-        setSelectedEffect(m_selectedEffect);
+        setSelectedEffect(0);
     }
     return parameters;
 }
@@ -1447,6 +1448,13 @@ void ClipItem::deleteEffect(QString index)
         }
     }
     m_effectNames = m_effectList.effectNames().join(" / ");
+    if (m_effectList.isEmpty() || m_selectedEffect - 1 == index.toInt()) {
+        // Current effect was removed
+        if (index.toInt() > m_effectList.count() - 1) {
+            setSelectedEffect(m_effectList.count() - 1);
+        } else setSelectedEffect(index.toInt());
+        return;
+    }
     if (needRepaint) update(boundingRect());
     flashClip();
 }
index d80cd53a2251bd65d24b069c3dfc158d9e9bcf48..d48c697ec1cfdf9fdb4b78b410c472cd0a8ca672 100644 (file)
@@ -1261,7 +1261,7 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem *
     int count = 0;
     for (int i = 0; i < itemList.count(); i++) {
         if (itemList.at(i)->type() == AVWIDGET) {
-            ClipItem *item = (ClipItem *)itemList.at(i);
+            ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
             if (item->hasEffect(effect.attribute("tag"), effect.attribute("id")) != -1 && effect.attribute("unique", "0") != "0") {
                 emit displayMessage(i18n("Effect already present in clip"), ErrorMessage);
                 continue;
@@ -1269,13 +1269,14 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem *
             if (item->isItemLocked()) {
                 continue;
             }
-            item->initEffect(effect);
+            QDomElement itemEffect = effect.cloneNode().toElement();
+            item->initEffect(itemEffect);
             if (effect.attribute("tag") == "ladspa") {
                 QString ladpsaFile = m_document->getLadspaFile();
                 initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
-                effect.setAttribute("src", ladpsaFile);
+                itemEffect.setAttribute("src", ladpsaFile);
             }
-            new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
+            new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), itemEffect, true, effectCommand);
             count++;
         }
     }