Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Crash on calling JS function from C++

18 views
Skip to first unread message

UAStudent

unread,
Jun 25, 2010, 12:48:04 AM6/25/10
to
Dear all,

Sorry if my question is too silly. I am new to SpiderMonkey and use it
for my GUI hobby project. My problem is that, if I set an event
handler of my GUI element in a script by function name or anonymous
function, the code will crash if the event handler is called.

For example,

suppose I set a button's OnClick event handler to an anonymous
function as following

button.OnClick = function(button, event) { button.Color =
"Red"; };

Then when the button is clicked, the event handler will be called and
its color property will be set to "Red". But after the function is
executed, the program will always fail @ the assertion of

Js_isActiveWithOrBlock

By debugging, I guess it's due to scope-chain stuff of the function
and there is something wrong will my function call approach.


Basically, in my code, I save a JSFunction* type of value when
"OnClick" property is set. Then when the button is clicked, I just use
JS_CallFunction to call the saved function.

It seems not quite right. Wish you gurus here could help me out. Many
thanks


0 new messages