Skip to content

Commit

Permalink
Only log completely absent script functions as an error
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards authored and huderlem committed Dec 31, 2021
1 parent 3bc9497 commit 98f4bae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
## [Unreleased]
### Changed
- If an object event is inanimate, it will always render using its first frame.
- Only log "Unknown custom script function" when a registered script function is not present in any script.

## [4.5.0] - 2021-12-26
### Added
Expand Down
8 changes: 5 additions & 3 deletions src/scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,20 @@ void Scripting::invokeAction(QString actionName) {
if (!instance) return;
if (!instance->registeredActions.contains(actionName)) return;

bool foundFunction = false;
QString functionName = instance->registeredActions.value(actionName);
for (QJSValue module : instance->modules) {
QJSValue callbackFunction = module.property(functionName);
if (callbackFunction.isUndefined() || !callbackFunction.isCallable()) {
logError(QString("Unknown custom script function '%1'").arg(functionName));
if (callbackFunction.isUndefined() || !callbackFunction.isCallable())
continue;
}
foundFunction = true;
if (tryErrorJS(callbackFunction)) continue;

QJSValue result = callbackFunction.call(QJSValueList());
if (tryErrorJS(result)) continue;
}
if (!foundFunction)
logError(QString("Unknown custom script function '%1'").arg(functionName));
}

void Scripting::cb_ProjectOpened(QString projectPath) {
Expand Down

0 comments on commit 98f4bae

Please sign in to comment.