From 506b35840ed6c3d165394cafb4e9951b8af0dc6d Mon Sep 17 00:00:00 2001 From: Tom Najdek Date: Wed, 31 May 2017 16:36:10 +0100 Subject: [PATCH] Add a shutdown hook in Zotero.Prefs to unregister observer * Without this, preference change observers stack, triggering multiple times if Zotero is re-initialized multiple times within the same browser instance (like in tests) --- chrome/content/zotero/xpcom/zotero.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 6506f182ee..9812caaa01 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1938,7 +1938,12 @@ Zotero.Prefs = new function(){ // Register observer to handle pref changes this.register(); - + + // Unregister observer handling pref changes + if (Zotero.addShutdownListener) { + Zotero.addShutdownListener(this.unregister.bind(this)); + } + // Process pref version updates var fromVersion = this.get('prefVersion'); if (!fromVersion) {