Instantiating an ObjectTemplate needs to create a JavaScript object in a JavaScript context. Therefore, you need to enter a context before the call to tmpl->NewInstance().
Cheers, -- Mads On Thu, Oct 1, 2009 at 2:18 PM, Chris <[email protected]> wrote: > > Is there something inherently wrong with the following: > > int main(int argc, char* argv[]) > { > V8::SetFlagsFromCommandLine(&argc, argv, true); > HandleScope handle_scope; > > Handle<ObjectTemplate> tmpl; > Handle<ObjectTemplate> raw_template = ObjectTemplate::New(); > tmpl = Persistent<ObjectTemplate>::New(raw_template); > Handle<Object> result = Persistent<Object>::New(tmpl->NewInstance > ()); > ... > } > > Segmentation fault occurs on the last line of code there. I notice > that if I create a Context and Scope beforehand then it does not > crash. What I don't understand is why the stack-allocated handle > scope is not enough or am I doing something else wrong maybe related > to Persistent handles? > > > --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
