commit ad8b81f4c7a076b07038990e766ca74482b4609e
parent fad6174e39c7de1a017c09f6c83d0097b696df3c
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 18 Jun 2014 05:03:06 -0400
Use Q instead of Task.spawn to run processUpdatedXML()
With Task.spawn, regular expressions in Zotero.DB were causing "too much
recursion" errors on Windows with JIT enabled.
This requires a change to Q to allow async() to take a generator instead
of a generator-maker (which is the reason it was using Task.spawn to
begin with).
Diffstat:
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js
@@ -1627,9 +1627,7 @@ Zotero.Sync.Server = new function () {
_error(e);
}
- Components.utils.import("resource://gre/modules/Task.jsm");
-
- Task.spawn(Zotero.Sync.Server.Data.processUpdatedXML(
+ Q.async(Zotero.Sync.Server.Data.processUpdatedXML(
responseNode.getElementsByTagName('updated')[0],
lastLocalSyncDate,
syncSession,
@@ -1838,7 +1836,7 @@ Zotero.Sync.Server = new function () {
Zotero.HTTP.doPost(url, body, uploadCallback);
}
}
- ))
+ ))()
.then(
null,
function (e) {
diff --git a/resource/q.js b/resource/q.js
@@ -1021,7 +1021,14 @@ function async(makeGenerator) {
}
return when(result, callback, errback);
}
- var generator = makeGenerator.apply(this, arguments);
+ // Added by Dan
+ // If already a generator, use that
+ if (makeGenerator.send) {
+ var generator = makeGenerator;
+ }
+ else {
+ var generator = makeGenerator.apply(this, arguments);
+ }
var callback = continuer.bind(continuer, "send");
var errback = continuer.bind(continuer, "throw");
return callback();