mirror of
https://github.com/phpv8/v8js.git
synced 2025-01-03 10:21:51 +00:00
Delete global PHP object on shutdown
Deleting the global object implicitly deletes all the properties, i.e. PHP objects we previously attached to it (and for which we increased the reference counter). Since the following idle notifications trigger the weak callbacks, the references on the PHP objects are finally decreased.
This commit is contained in:
parent
18b129b128
commit
68a579f3ae
11
v8js.cc
11
v8js.cc
@ -512,6 +512,17 @@ static void php_v8js_free_storage(void *object TSRMLS_DC) /* {{{ */
|
||||
zval_ptr_dtor(&c->pending_exception);
|
||||
}
|
||||
|
||||
/* Delete PHP global object from JavaScript */
|
||||
if (!c->context.IsEmpty()) {
|
||||
v8::Locker locker(c->isolate);
|
||||
v8::Isolate::Scope isolate_scope(c->isolate);
|
||||
v8::HandleScope handle_scope(c->isolate);
|
||||
v8::Context::Scope context_scope(c->isolate, c->context);
|
||||
|
||||
v8::Local<v8::String> object_name_js = v8::Local<v8::String>::New(c->isolate, c->object_name);
|
||||
V8JS_GLOBAL->Delete(object_name_js);
|
||||
}
|
||||
|
||||
c->object_name.Reset();
|
||||
c->object_name.~Persistent();
|
||||
c->global_template.Reset();
|
||||
|
Loading…
Reference in New Issue
Block a user