Commit 5500facc authored by Volker Krause's avatar Volker Krause
Browse files

Pass the triggering node to the extractor script as a third argument

This is needed to phase out the global Context object, which is what we
use so far to convey information about the triggering data.
parent a789129e
...@@ -108,7 +108,11 @@ ExtractorResult ExtractorScriptEngine::execute(const ScriptExtractor *extractor, ...@@ -108,7 +108,11 @@ ExtractorResult ExtractorScriptEngine::execute(const ScriptExtractor *extractor,
qCDebug(Log) << "Running script extractor" << extractor->scriptFileName() << extractor->scriptFunction(); qCDebug(Log) << "Running script extractor" << extractor->scriptFileName() << extractor->scriptFunction();
node.setScriptEngine(&d->m_engine); node.setScriptEngine(&d->m_engine);
const auto engineReset = qScopeGuard([&node]{ node.setScriptEngine(nullptr); }); triggerNode.setScriptEngine(&d->m_engine);
const auto engineReset = qScopeGuard([&node, &triggerNode]{
node.setScriptEngine(nullptr);
triggerNode.setScriptEngine(nullptr);
});
// ### legacy context API, replace that by passing trigger node as a third argument eventually // ### legacy context API, replace that by passing trigger node as a third argument eventually
if (triggerNode.result().isEmpty()) { if (triggerNode.result().isEmpty()) {
...@@ -142,7 +146,8 @@ ExtractorResult ExtractorScriptEngine::execute(const ScriptExtractor *extractor, ...@@ -142,7 +146,8 @@ ExtractorResult ExtractorScriptEngine::execute(const ScriptExtractor *extractor,
const auto nodeArg = d->m_engine.toScriptValue(node); const auto nodeArg = d->m_engine.toScriptValue(node);
const auto dataArg = nodeArg.property(QLatin1String("content")); const auto dataArg = nodeArg.property(QLatin1String("content"));
QJSValueList args{ dataArg, nodeArg }; const auto triggerArg = d->m_engine.toScriptValue(triggerNode);
QJSValueList args{ dataArg, nodeArg, triggerArg };
const auto result = mainFunc.call(args); const auto result = mainFunc.call(args);
if (result.isError()) { if (result.isError()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment