commit 9a0457b43e984e5d83ef5382bc5c15e7a8d09865
parent 635d2e48b966d36d99df0416e9bd5e63c48b9018
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 1 Aug 2006 18:01:56 +0000
Register shutdown handler to call Scholar.shutdown() on exit
Diffstat:
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/scholar.js b/chrome/chromeFiles/content/scholar/xpcom/scholar.js
@@ -14,10 +14,12 @@ const SCHOLAR_CONFIG = {
*/
var Scholar = new function(){
var _initialized = false;
+ var _shutdown = false;
var _localizedStringBundle;
// Privileged (public) methods
this.init = init;
+ this.shutdown = shutdown;
this.getProfileDirectory = getProfileDirectory;
this.getScholarDirectory = getScholarDirectory;
this.getStorageDirectory = getStorageDirectory;
@@ -42,6 +44,15 @@ var Scholar = new function(){
return false;
}
+ // Register shutdown handler to call Scholar.shutdown()
+ var observerService = Components.classes["@mozilla.org/observer-service;1"]
+ .getService(Components.interfaces.nsIObserverService);
+ observerService.addObserver({
+ observe: function(subject, topic, data){
+ Scholar.shutdown(subject, topic, data)
+ }
+ }, "xpcom-shutdown", false);
+
// Load in the preferences branch for the extension
Scholar.Prefs.init();
@@ -75,6 +86,16 @@ var Scholar = new function(){
}
+ function shutdown(subject, topic, data){
+ // Called twice otherwise, for some reason
+ if (_shutdown){
+ return false;
+ }
+
+ _shutdown = true;
+ }
+
+
function getProfileDirectory(){
return Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)