From 0290f4aa0f347c23d55790237cfd85898f10938b Mon Sep 17 00:00:00 2001 From: slopjong Date: Tue, 6 Mar 2012 22:15:22 +0100 Subject: [PATCH] Unregister the window when unloaded. --- chrome/content/openspace.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/chrome/content/openspace.js b/chrome/content/openspace.js index 53cd3e0..4132f5c 100644 --- a/chrome/content/openspace.js +++ b/chrome/content/openspace.js @@ -1,11 +1,10 @@ -// TODO: when to unregister this window? - var openspace = { /** * Loads some modules and populates the listbox with spaces known - * in the space directory. + * in the space directory. After the initialization this object + * is registered as an observer in the OpenSpace javascript module. */ onLoad: function() { @@ -45,6 +44,13 @@ var openspace = { this.initialized = true; }, + /** + * Unregisters this object as an observer in the OpenSpace javascript module. + */ + onUnLoad: function(){ + unregisterOpenSpaceObserver(this); + }, + /** * Displays a green, red or a grey dot. The colors have the following meaning: * @@ -147,4 +153,5 @@ var openspace = { } }; -window.addEventListener("load", function(e) { openspace.onLoad(e); }, false); \ No newline at end of file +window.addEventListener("load", function(e) { openspace.onLoad(e); }, false); +window.addEventListener("unload", function(e){ openspace.onUnLoad(e); }, false); \ No newline at end of file