diff --git a/src/cpp/lib/core/WrapperCache/wrappercache.cpp b/src/cpp/lib/core/WrapperCache/wrappercache.cpp index d99637251..8b14dee68 100644 --- a/src/cpp/lib/core/WrapperCache/wrappercache.cpp +++ b/src/cpp/lib/core/WrapperCache/wrappercache.cpp @@ -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); } diff --git a/src/lib/core/WrapperCache.ts b/src/lib/core/WrapperCache.ts index 23c2689e2..794e9a646 100644 --- a/src/lib/core/WrapperCache.ts +++ b/src/lib/core/WrapperCache.ts @@ -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(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; }