Do not dereference remote callback if its renderer view is released.
This commit is contained in:
parent
1e1fec15b6
commit
caaab22841
2 changed files with 8 additions and 1 deletions
|
@ -39,7 +39,7 @@ class ObjectsStore
|
|||
key = "#{processId}_#{routingId}"
|
||||
delete @stores[key]
|
||||
|
||||
class ObjectsRegistry
|
||||
class ObjectsRegistry extends EventEmitter
|
||||
constructor: ->
|
||||
# Objects in weak map will be not referenced (so we won't leak memory), and
|
||||
# every object created in browser will have a unique id in weak map.
|
||||
|
@ -84,6 +84,7 @@ class ObjectsRegistry
|
|||
|
||||
# Clear all references to objects from renderer view.
|
||||
clear: (processId, routingId) ->
|
||||
@emit "release-renderer-view-#{processId}-#{routingId}"
|
||||
ObjectsStore.releaseForRenderView processId, routingId
|
||||
|
||||
# Return an array of all browser windows.
|
||||
|
|
|
@ -52,9 +52,15 @@ unwrapArgs = (processId, routingId, args) ->
|
|||
returnValue = metaToValue meta.value
|
||||
-> returnValue
|
||||
when 'function'
|
||||
rendererReleased = false
|
||||
objectsRegistry.once "release-renderer-view-#{processId}-#{routingId}", ->
|
||||
rendererReleased = true
|
||||
|
||||
ret = ->
|
||||
throw new Error('Calling a callback of released renderer view') if rendererReleased
|
||||
ipc.sendChannel processId, routingId, 'ATOM_RENDERER_CALLBACK', meta.id, valueToMeta(processId, routingId, arguments)
|
||||
v8Util.setDestructor ret, ->
|
||||
return if rendererReleased
|
||||
ipc.sendChannel processId, routingId, 'ATOM_RENDERER_RELEASE_CALLBACK', meta.id
|
||||
ret
|
||||
else throw new TypeError("Unknown type: #{meta.type}")
|
||||
|
|
Loading…
Reference in a new issue