- QString effectString = scriptEngine.globalObject().property("update").call(QScriptValue(), QScriptValueList() << serviceVersion << effectVersion << scriptDoc.toString()).toString();
-
- if (!effectString.isEmpty()) {
- scriptDoc.setContent(effectString);
- QDomNode updatedEffect = effect.ownerDocument().importNode(scriptDoc.documentElement(), true);
- effect.parentNode().replaceChild(updatedEffect, effect);
- // TODO: set version to avoid dependency on latest MLT
- m_modified = true;
+ QScriptValue updateRules = scriptEngine.globalObject().property("update");
+ if (!updateRules.isValid())
+ continue;
+ if (updateRules.isFunction()) {
+ QDomDocument scriptDoc;
+ scriptDoc.appendChild(scriptDoc.importNode(effect, true));
+
+ QString effectString = updateRules.call(QScriptValue(), QScriptValueList() << serviceVersion << effectVersion << scriptDoc.toString()).toString();
+
+ if (!effectString.isEmpty() && !scriptEngine.hasUncaughtException()) {
+ scriptDoc.setContent(effectString);
+ QDomNode updatedEffect = effect.ownerDocument().importNode(scriptDoc.documentElement(), true);
+ effect.parentNode().replaceChild(updatedEffect, effect);
+ m_modified = true;
+ }
+ } else {
+ m_modified = updateEffectParameters(effect.childNodes(), &updateRules, serviceVersion, effectVersion);
+ }
+
+ // set version number since MLT won't change it (only initially set it)
+ QDomElement versionElem = effect.firstChildElement("version");
+ if (EffectsList::property(effect, "version").isNull()) {
+ versionElem = effect.ownerDocument().createTextNode(QLocale().toString(serviceVersion)).toElement();
+ versionElem.setTagName("property");
+ versionElem.setAttribute("name", "version");
+ effect.appendChild(versionElem);
+ } else {
+ EffectsList::setProperty(effect, "version", QLocale().toString(serviceVersion));