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).
This commit is contained in:
Dan Stillman 2014-06-18 05:03:06 -04:00
parent fad6174e39
commit ad8b81f4c7
2 changed files with 10 additions and 5 deletions

View file

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

View file

@ -1021,7 +1021,14 @@ function async(makeGenerator) {
}
return when(result, callback, errback);
}
// 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();