slosd / guiconfig

gui:config - A Firefox add-on which provides advanced configuration for the browser
https://addons.mozilla.org/en-US/firefox/addon/guiconfig
GNU General Public License v3.0
9 stars 1 forks source link

Button onCommand handler references closed window #28

Closed slosd closed 9 years ago

slosd commented 9 years ago

The onCommand handler of the toolbar button always references the first opened window, which causes this exception if that window has been closed:

Exception { message: "", result: 2147746065, name: "NS_ERROR_NOT_AVAILABLE", filename: "chrome://guiconfig/content/browser.js", lineNumber: 153, columnNumber: 0, inner: null, data: null, stack: "showPreferencesDialog@chrome://guiconfig/content/browser.js:153:13
_addToolbarButton_customizableUI/<.onCommand@chrome://guiconfig/content/browser.js:106:8
CustomizableUIInternal.handleWidgetCommand@resource://app/modules/CustomizableUI.jsm:1355:10
", location: XPCWrappedNative_NoHelper }

The correct window is the one referenced in the event object:

onCommand: function(event) {
  var win = event.target.ownerDocument.defaultView;
}