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)
This commit is contained in:
Tom Najdek 2017-05-31 16:36:10 +01:00 committed by Dan Stillman
parent aa6037c088
commit 506b35840e

View file

@ -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) {