From: Cheng Zhao Date: Mon, 20 May 2013 06:55:46 +0000 (+0800) Subject: Erase window from weak map immediately after it's destroyed. X-Git-Tag: v0.1.0~144 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=d19e62d8672b679914d1f7639f6e69d49be25ae0;p=electron.git Erase window from weak map immediately after it's destroyed. Otherwise it could happend that developers accessed the window after it's destroyed but before it's GCed. --- diff --git a/browser/atom/objects_registry.coffee b/browser/atom/objects_registry.coffee index 3dcdd581..ccd2a913 100644 --- a/browser/atom/objects_registry.coffee +++ b/browser/atom/objects_registry.coffee @@ -55,7 +55,10 @@ process.on 'ATOM_BROWSER_INTERNAL_NEW', (obj) -> objectsWeakMap.add obj # Also remember all windows. - windowsWeakMap.add obj if obj.constructor is BrowserWindow + if obj.constructor is BrowserWindow + id = windowsWeakMap.add obj + obj.on 'destroyed', -> + windowsWeakMap.remove id exports.add = (processId, routingId, obj) -> # Some native objects may already been added to objectsWeakMap, be care not