소스 검색

fix(scripting): correct inverted vector component validation in jsToDynamicValue (#618)

ScriptEngine::jsToDynamicValue guards the JS->glm::vec conversion with:

    if (!JS_IsNumber (x) || JS_IsNumber (y)) {
        sLog.exception ("Vector's x and y components must be numbers");
    }

The second clause is missing a '!': a valid numeric y triggers the
exception (since sLog.exception is [[noreturn]] and throws runtime_error).
That breaks every JS->vec2/vec3/vec4 conversion from a scene script as
soon as the script passes a real vector literal.

Caught while auditing the scripting refactor in #599. Restore the
intended predicate so both x and y must be non-numeric to throw.
David Mireles 1 개월 전
부모
커밋
58a7f14ac1
1개의 변경된 파일과 1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/WallpaperEngine/Scripting/ScriptEngine.cpp

+ 1 - 1
src/WallpaperEngine/Scripting/ScriptEngine.cpp

@@ -153,7 +153,7 @@ static void jsToDynamicValue (JSContext* ctx, JSValue val, DynamicValue& source)
 	    JS_FreeValue (ctx, w);
 	});
 
-	if (!JS_IsNumber (x) || JS_IsNumber (y)) {
+	if (!JS_IsNumber (x) || !JS_IsNumber (y)) {
 	    sLog.exception ("Vector's x and y components must be numbers");
 	}