commit dd9cc40c16ef9171b645a2fd021a5ac586714678
parent 6907af86fdb0ca8cbdcd3446536ed267863ea1e5
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 17 May 2016 11:50:26 -0400
Cancel pending feed update check on Zotero shutdown
This avoids errors for a missing 'feeds' table during tests, when the callback
started in Zotero.Feeds.init() runs but the Zotero object has been torn down
and the database hasn't yet been reinitialized.
Diffstat:
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/feeds.js b/chrome/content/zotero/xpcom/data/feeds.js
@@ -26,8 +26,18 @@
// Mimics Zotero.Libraries
Zotero.Feeds = new function() {
this.init = function () {
- setTimeout(() => this.scheduleNextFeedCheck(), 5000);
- }
+ this._timeoutID = setTimeout(() => {
+ this.scheduleNextFeedCheck();
+ this._timeoutID = null;
+ }, 5000);
+ };
+
+ this.uninit = function () {
+ if (this._timeoutID) {
+ clearTimeout(this._timeoutID);
+ this._timeoutID = null
+ }
+ };
this._cache = null;
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -736,6 +736,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
Zotero.Items.startEmptyTrashTimer();
Zotero.Feeds.init();
+ Zotero.addShutdownListener(() => Zotero.Feeds.uninit());
return true;
}