]> git.sesse.net Git - kdenlive/blobdiff - src/effectstackview.cpp
Fix crash when adding kdeyframe effect
[kdenlive] / src / effectstackview.cpp
index 45a5169b757311ed22604f9441214c5a4d45dc9d..2ef1db1e7e6d3cc387ab570bf2fe688ac6357151 100644 (file)
@@ -48,7 +48,7 @@ EffectStackView::EffectStackView(QWidget *parent) :
     m_ui.buttonUp->setToolTip(i18n("Move effect up"));
     m_ui.buttonDown->setIcon(KIcon("go-down"));
     m_ui.buttonDown->setToolTip(i18n("Move effect down"));
-    m_ui.buttonDel->setIcon(KIcon("trash-empty"));
+    m_ui.buttonDel->setIcon(KIcon("edit-delete"));
     m_ui.buttonDel->setToolTip(i18n("Delete effect"));
     m_ui.buttonSave->setIcon(KIcon("document-save"));
     m_ui.buttonSave->setToolTip(i18n("Save effect"));
@@ -65,8 +65,7 @@ EffectStackView::EffectStackView(QWidget *parent) :
     connect(m_ui.buttonDel, SIGNAL(clicked()), this, SLOT(slotItemDel()));
     connect(m_ui.buttonSave, SIGNAL(clicked()), this, SLOT(slotSaveEffect()));
     connect(m_ui.buttonReset, SIGNAL(clicked()), this, SLOT(slotResetEffect()));
-    connect(this, SIGNAL(transferParamDesc(const QDomElement&, int , int)), m_effectedit , SLOT(transferParamDesc(const QDomElement&, int , int)));
-    connect(m_effectedit, SIGNAL(parameterChanged(const QDomElement&, const QDomElement&)), this , SLOT(slotUpdateEffectParams(const QDomElement&, const QDomElement&)));
+    connect(m_effectedit, SIGNAL(parameterChanged(const QDomElement, const QDomElement)), this , SLOT(slotUpdateEffectParams(const QDomElement, const QDomElement)));
     m_effectLists["audio"] = &MainWindow::audioEffects;
     m_effectLists["video"] = &MainWindow::videoEffects;
     m_effectLists["custom"] = &MainWindow::customEffects;
@@ -75,6 +74,12 @@ EffectStackView::EffectStackView(QWidget *parent) :
     setEnabled(false);
 }
 
+EffectStackView::~EffectStackView()
+{
+    m_effectLists.clear();
+    delete m_effectedit;
+}
+
 void EffectStackView::setMenu(QMenu *menu)
 {
     m_ui.buttonNew->setMenu(menu);
@@ -121,7 +126,7 @@ void EffectStackView::slotSaveEffect()
     emit reloadEffects();
 }
 
-void EffectStackView::slotUpdateEffectParams(const QDomElement& old, const QDomElement& e)
+void EffectStackView::slotUpdateEffectParams(const QDomElement old, const QDomElement e)
 {
     if (m_clipref)
         emit updateClipEffect(m_clipref, old, e, m_ui.effectlist->currentRow());
@@ -150,6 +155,7 @@ void EffectStackView::slotItemChanged(QListWidgetItem *item)
 {
     bool disable = true;
     if (item->checkState() == Qt::Checked) disable = false;
+    m_ui.frame->setEnabled(!disable);
     m_ui.buttonReset->setEnabled(!disable);
     int activeRow = m_ui.effectlist->currentRow();
     if (activeRow >= 0) {
@@ -167,7 +173,7 @@ void EffectStackView::setupListView(int ix)
     KIcon audioIcon("kdenlive-show-audio");
     QListWidgetItem* item;
 
-    for (int i = 0;i < m_clipref->effectsCount();i++) {
+    for (int i = 0; i < m_clipref->effectsCount(); i++) {
         QDomElement d = m_clipref->effectAt(i);
 
         QDomNode namenode = d.elementsByTagName("name").item(0);
@@ -188,7 +194,7 @@ void EffectStackView::setupListView(int ix)
         }
     }
     if (m_clipref->effectsCount() == 0) {
-        emit transferParamDesc(QDomElement(), 0, 0);
+        m_effectedit->transferParamDesc(QDomElement(), 0, 0);
         m_ui.buttonDel->setEnabled(false);
         m_ui.buttonSave->setEnabled(false);
         m_ui.buttonReset->setEnabled(false);
@@ -213,7 +219,7 @@ void EffectStackView::slotItemSelectionChanged()
     bool isChecked = false;
     if (hasItem && m_ui.effectlist->currentItem()->checkState() == Qt::Checked) isChecked = true;
     if (hasItem && m_ui.effectlist->currentItem()->isSelected()) {
-        emit transferParamDesc(m_clipref->effectAt(activeRow), m_clipref->cropStart().frames(KdenliveSettings::project_fps()), m_clipref->cropDuration().frames(KdenliveSettings::project_fps()));//minx max frame
+        m_effectedit->transferParamDesc(m_clipref->effectAt(activeRow), m_clipref->cropStart().frames(KdenliveSettings::project_fps()), m_clipref->cropDuration().frames(KdenliveSettings::project_fps()));//minx max frame
     }
     if (m_clipref) m_clipref->setSelectedEffect(activeRow);
     m_ui.buttonDel->setEnabled(hasItem);
@@ -221,6 +227,7 @@ void EffectStackView::slotItemSelectionChanged()
     m_ui.buttonReset->setEnabled(hasItem && isChecked);
     m_ui.buttonUp->setEnabled(activeRow > 0);
     m_ui.buttonDown->setEnabled((activeRow < m_ui.effectlist->count() - 1) && hasItem);
+    m_ui.frame->setEnabled(isChecked);
 }
 
 void EffectStackView::slotItemUp()
@@ -255,13 +262,14 @@ void EffectStackView::slotResetEffect()
     foreach(const QString &type, m_effectLists.keys()) {
         EffectsList *list = m_effectLists[type];
         if (list->effectNames().contains(effectName)) {
-            dom = list->getEffectByName(effectName);
+            dom = list->getEffectByName(effectName).cloneNode().toElement();
             break;
         }
     }
     if (!dom.isNull()) {
         dom.setAttribute("kdenlive_ix", old.attribute("kdenlive_ix"));
-        emit transferParamDesc(dom, m_clipref->cropStart().frames(KdenliveSettings::project_fps()), m_clipref->cropDuration().frames(KdenliveSettings::project_fps()));//minx max frame
+        m_clipref->initEffect(dom);
+        m_effectedit->transferParamDesc(dom, m_clipref->cropStart().frames(KdenliveSettings::project_fps()), m_clipref->cropDuration().frames(KdenliveSettings::project_fps()));//minx max frame
         emit updateClipEffect(m_clipref, old, dom, activeRow);
     }
 }