Open flybird opened 8 years ago
I'm also getting this issue
I was able to trivially reproduce this by running the line
CCASSERT(ScriptingCore::getInstance()->evalString("(function() { cc.log ('World Hello!'); })();"), "Testing EvalString");
in AppDelegate.cpp after ScriptingCore initialization. The reasoning seems to be that we are initializing the JS::PersistentRootedScript without an initialization value, which will mean it's operator== against nullptr will return true. Like the reporter suggests we should use the overridden operator& of the script, comparing that against nullptr.
Also on a slightly related note, I am unsure on why we are using a JS::PersistentRootedScript here over a JS::RootedScript. The script in this use case has a definite lifetime, and is not cached or stored globally, so I see no point for using a PersistentRooted
I will submit a PR that fixes this issue. @pandamicro
Yes, you are right, this was due to code merging, I used to new a PersistentRootedScript, and delete it at the end, but totally it's useless, let's use JS::RootedScript.
Sorry for the trouble.
Steps to Reproduce: I use latest version 3.13. I found I call ScriptingCore::evalString but It don't fire. the code always return false, the "script" is nullptr,
I think it should be compare with point "&script"