From: Cheng Zhao Date: Sat, 4 May 2013 13:52:14 +0000 (+0800) Subject: Clear listeners on process object when unloading. X-Git-Tag: v0.1.0~208 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=84dc221b2e03cf92e8ce091c5ed6201e85e372b7;p=electron.git 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. --- diff --git a/renderer/api/lib/ipc.coffee b/renderer/api/lib/ipc.coffee index 2ef1290d..28b9a969 100644 --- a/renderer/api/lib/ipc.coffee +++ b/renderer/api/lib/ipc.coffee @@ -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...)