diff options
Diffstat (limited to 'src/embind/embind.js')
-rw-r--r-- | src/embind/embind.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 124ea569..8c8d73ad 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -1216,9 +1216,18 @@ RegisteredPointer.prototype['fromWireType'] = function fromWireType(ptr) { var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer); if (undefined !== registeredInstance) { - var rv = registeredInstance['clone'](); - this.destructor(ptr); - return rv; + // JS object has been neutered, time to repopulate it + if (0 === registeredInstance.$$.count.value) { + registeredInstance.$$.ptr = rawPointer; + registeredInstance.$$.smartPtr = ptr; + return registeredInstance['clone'](); + } else { + // else, just increment reference count on existing object + // it already has a reference to the smart pointer + var rv = registeredInstance['clone'](); + this.destructor(ptr); + return rv; + } } function makeDefaultHandle() { |