diff --git a/Runtime/Helpers/Callback.cs b/Runtime/Helpers/Callback.cs index ce6f47e9..2f7219a8 100644 --- a/Runtime/Helpers/Callback.cs +++ b/Runtime/Helpers/Callback.cs @@ -104,7 +104,7 @@ public object Call(params object[] args) { var res = context.FireEventByRefCallback?.Call(i, args); #if REACT_QUICKJS - (context.Script.Engine as Scripting.QuickJSEngine)?.Runtime.ExecutePendingJob(); + (context.Script.Engine as Scripting.QuickJSEngine)?.Runtime?.ExecutePendingJob(); #endif return res; } @@ -114,7 +114,7 @@ public object Call(params object[] args) // TODO: because of an error in ClearScipt, arrays cannot be iterated (Mono bug?) so.Engine.Global.SetProperty("__temp__", so); so.Engine.Global.SetProperty("__args__", args?.ToList()); - var res = so.Engine.Evaluate(null, true, "var res = __temp__(...(__args__ || [])); delete __temp__; delete __args__; res;"); + var res = so.Engine?.Evaluate(null, true, "var res = __temp__(...(__args__ || [])); delete __temp__; delete __args__; res;"); return res; } #endif @@ -122,7 +122,7 @@ public object Call(params object[] args) else if (callback is QuickJS.ScriptFunction sf) { var res = sf.Invoke(args); - QuickJS.ScriptEngine.GetRuntime(sf.ctx).ExecutePendingJob(); + QuickJS.ScriptEngine.GetRuntime(sf.ctx)?.ExecutePendingJob(); return res; } else if (callback is QuickJS.ScriptValue sv) @@ -130,17 +130,17 @@ public object Call(params object[] args) var sff = new QuickJS.ScriptFunction(QuickJS.ScriptEngine.GetContext(sv.ctx), sv); var res = sff.Invoke(args); sff.Dispose(); - QuickJS.ScriptEngine.GetRuntime(sv.ctx).ExecutePendingJob(); + QuickJS.ScriptEngine.GetRuntime(sv.ctx)?.ExecutePendingJob(); return res; } else if (callback is QuickJS.Native.JSValue qf) { - var eg = (context?.Script.Engine as Scripting.QuickJSEngine); + var eg = (context?.Script?.Engine as Scripting.QuickJSEngine); if (eg == null) return null; var sff = new QuickJS.ScriptFunction(eg.MainContext, qf); var res = sff.Invoke(args); sff.Dispose(); - eg?.Runtime.ExecutePendingJob(); + eg?.Runtime?.ExecutePendingJob(); return res; } #endif