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));
}
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));
// 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()) {
} 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)) {
currenteffect.setAttribute("src", ladspaEffectFile);
}
item->addEffect(currenteffect, false);
- item->effectsCounter();
}
}
}