Skip to content

Commit

Permalink
Menu commander: use weak references to browsers.
Browse files Browse the repository at this point in the history
In an attempt to not leak them?

Refs greasemonkey#2067
  • Loading branch information
arantius committed Jul 7, 2015
1 parent 50e8dd4 commit 8360d3b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions content/menucommander.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Components.utils.import('chrome://greasemonkey-modules/content/util.js');
var Cu = Components.utils;

Cu.import('chrome://greasemonkey-modules/content/util.js');

var GM_MenuCommander = {
menuCommands: {}
Expand All @@ -24,7 +26,7 @@ GM_MenuCommander.menuCommandRegistered = function(aMessage) {
}

var command = aMessage.data;
command.browser = aMessage.target;
command.browser = Cu.getWeakReference(aMessage.target);
GM_MenuCommander.menuCommands[windowId].push(command);
};

Expand All @@ -45,10 +47,11 @@ GM_MenuCommander.toggleMenuCommands = function(aMessage) {
};

GM_MenuCommander.commandClicked = function(aCommand) {
aCommand.browser.messageManager.sendAsyncMessage("greasemonkey:menu-command-clicked", {
index: aCommand.index,
windowId: aCommand.windowId
});
aCommand.browser.get().messageManager.sendAsyncMessage(
"greasemonkey:menu-command-clicked", {
index: aCommand.index,
windowId: aCommand.windowId
});
};

GM_MenuCommander.createMenuItem = function(command) {
Expand Down

0 comments on commit 8360d3b

Please sign in to comment.