Bug 751546: Fix "dead object" exception in api-utils/tab/observer. #425

Merged
merged 1 commit into from May 3, 2012
@@ -71,6 +71,12 @@ windowObserver.on("open", onWindowOpen);
function onWindowClose(chromeWindow) {
if (!isBrowser(chromeWindow)) return; // Ignore if it's not a browser window.
+ // Bug 751546: Emit `deactivate` event on window close immediatly
+ // Otherwise we are going to face "dead object" exception on `select` event
+ if (getActiveTab(chromeWindow) == selectedTab) {
+ observer._emit("deactivate", selectedTab);
@Gozala

Gozala May 3, 2012

Member

Don't you need to remove _emit('deactivate', ... it from wherever it was called before ?

@ochameau

ochameau May 3, 2012

Member

I don't think so as I'm nullifying selectedTab.
deactivate seems to be only fired from here:
https://github.com/ochameau/addon-sdk/blob/9ef15ef357a8fc9776fc25b9a8a9903804b5319f/packages/api-utils/lib/tabs/observer.js#L56

But you should have a better picture of this whole API as you wrote it,
so if you think I should do otherwise, please tell me.

@Gozala

Gozala May 3, 2012

Member

Yeah it's a mess there, but it looks like you're right.

+ selectedTab = null;
+ }
getTabContainers(chromeWindow).forEach(function (container) {
observer.ignore(container);
});