]> khamidou — GitHub mirrors - electron.git/commitdiff
Clear listeners on process object when unloading.
authorCheng Zhao <zcbenz@gmail.com>
Sat, 4 May 2013 13:52:14 +0000 (21:52 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 4 May 2013 13:52:14 +0000 (21:52 +0800)
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.

renderer/api/lib/ipc.coffee

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