mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 09:35:00 +09:00
js addon: call shutdown and discard eventHandler when unloading
This commit is contained in:
parent
fd5b6e6d8f
commit
76c3c885a0
2 changed files with 11 additions and 0 deletions
|
@ -41,6 +41,11 @@ func Command(cmd *C.char, data unsafe.Pointer, dataLen C.int, callback C.proxyFu
|
|||
})
|
||||
}
|
||||
|
||||
//export Shutdown
|
||||
func Shutdown() {
|
||||
service.Shutdown(nil)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
|
|
|
@ -204,6 +204,10 @@ static napi_value GetMethod(napi_env env, napi_callback_info info) {
|
|||
}
|
||||
|
||||
static void addon_is_unloading(napi_env env, void * data, void * hint) {
|
||||
printf("native addon is unloading\n");
|
||||
SetEventHandler(NULL, NULL);
|
||||
Shutdown();
|
||||
|
||||
AddonData * addon_data = (AddonData * ) data;
|
||||
assert(napi_delete_reference(env,
|
||||
addon_data->thread_item_constructor) == napi_ok);
|
||||
|
@ -352,6 +356,8 @@ NAPI_MODULE_INIT( /*napi_env env, napi_value exports*/ ) {
|
|||
AddonData * addon_data =
|
||||
memset(malloc(sizeof( * addon_data)), 0, sizeof( * addon_data));
|
||||
|
||||
printf("native addon init\n");
|
||||
|
||||
// Attach the addon data to the exports object to ensure that they are
|
||||
// destroyed together.
|
||||
assert(napi_wrap(env,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue