Make the wrapper cache callback work
This commit is contained in:
parent
710cfa3d31
commit
123123605c
@ -56,15 +56,16 @@ void WrapperCache::handleDestroyed(const QObject* object) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t result = 0;
|
||||
Napi::Env env = this->cache[object].env;
|
||||
napi_reference_unref(env, this->cache[object].ref, &result);
|
||||
this->cache.remove(object);
|
||||
|
||||
// Callback to JS with the address/ID of the destroyed object. So that it
|
||||
// can clear it out of the cache.
|
||||
if (destroyedCallback) {
|
||||
Napi::Env env = destroyedCallback.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
destroyedCallback.Call(
|
||||
{Napi::Value::From(env, extrautils::hashPointerTo53bit(object))});
|
||||
}
|
||||
|
||||
uint32_t result = 0;
|
||||
napi_reference_unref(this->cache[object].env, this->cache[object].ref, &result);
|
||||
this->cache.remove(object);
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ export class WrapperCache {
|
||||
}
|
||||
|
||||
private _objectDestroyedCallback(objectId: number): void {
|
||||
console.log(`_objectDestroyedCallback() id: ${objectId}`);
|
||||
if (!this._cache.has(objectId)) {
|
||||
return;
|
||||
}
|
||||
@ -30,9 +29,6 @@ export class WrapperCache {
|
||||
|
||||
get<T>(wrapperConstructor: { new (native: any): T }, native: any): T {
|
||||
const id = native.__id__();
|
||||
|
||||
console.log(`WrapperCache.get() id: ${id}`);
|
||||
|
||||
if (this._cache.has(id)) {
|
||||
return this._cache.get(id) as T;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user