Clear listeners on process object when unloading.

The process object is created under node context, and it will live
through the reloading, so we are responsible for clearing the listeners
to make sure resources are not leaked.
This commit is contained in:
Cheng Zhao 2013-05-04 21:52:14 +08:00
parent 6bf0d5d798
commit 84dc221b2e

View file

@ -6,6 +6,9 @@ class Ipc extends EventEmitter
process.on 'ATOM_INTERNAL_MESSAGE', (args...) => process.on 'ATOM_INTERNAL_MESSAGE', (args...) =>
@emit(args...) @emit(args...)
window.addEventListener 'unload', (event) ->
process.removeAllListeners 'ATOM_INTERNAL_MESSAGE'
send: (args...) -> send: (args...) ->
ipc.send('ATOM_INTERNAL_MESSAGE', 'message', args...) ipc.send('ATOM_INTERNAL_MESSAGE', 'message', args...)