From: Cheng Zhao Date: Sat, 4 May 2013 14:57:17 +0000 (+0800) Subject: Check whether id is valid when adding to weak map. X-Git-Tag: v0.1.0~207 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=e7547363e2d3d776ef8eef9b2c0800c4a80fcdb0;p=electron.git Check whether id is valid when adding to weak map. It's possible that the object has been added to weak map before and then erased, so having an id property doesn't mean it's added in the weak map. --- diff --git a/browser/atom/objects_registry.coffee b/browser/atom/objects_registry.coffee index f921eb64..73613ae3 100644 --- a/browser/atom/objects_registry.coffee +++ b/browser/atom/objects_registry.coffee @@ -59,7 +59,7 @@ process.on 'ATOM_BROWSER_INTERNAL_NEW', (obj) -> exports.add = (processId, routingId, obj) -> # Some native objects may already been added to objectsWeakMap, be care not # to add it twice. - objectsWeakMap.add obj unless obj.id? + objectsWeakMap.add obj unless obj.id? and objectsWeakMap.has obj.id # Store and reference the object, then return the storeId which points to # where the object is stored. The caller can later dereference the object