Check whether sender is destroyed before calling sender.send

Fix #4279.
This commit is contained in:
Cheng Zhao 2016-01-30 12:58:21 +08:00
parent 5d16257c2d
commit 3f68b2f227

View file

@ -162,12 +162,12 @@ var unwrapArgs = function(sender, args) {
});
let callIntoRenderer = function(...args) {
if (rendererReleased)
if (rendererReleased || sender.isDestroyed())
throw new Error(`Attempting to call a function in a renderer window that has been closed or released. Function provided here: ${meta.location}.`);
sender.send('ATOM_RENDERER_CALLBACK', meta.id, valueToMeta(sender, args));
};
v8Util.setDestructor(callIntoRenderer, function() {
if (!rendererReleased)
if (!rendererReleased && !sender.isDestroyed())
sender.send('ATOM_RENDERER_RELEASE_CALLBACK', meta.id);
});
sender.callbacks.set(meta.id, callIntoRenderer);