commit 9d3f55be5193763d4c6d2afc3ddecea0bf5a9f39
parent b6f493207f987b71beff53d505369ea5b504dece
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 7 Aug 2013 11:01:12 -0400
Use async DB for autocomplete
This was probably hanging previously because I was passing a JS function for
onProgress, which apparently isn't allowed.
Diffstat:
2 files changed, 3 insertions(+), 35 deletions(-)
diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js
@@ -794,7 +794,7 @@ Zotero.DBConnection.prototype.checkException = function (e) {
Zotero.DBConnection.prototype.closeDatabase = function () {
if(this._connection) {
this.stopDummyStatement();
- this._connection.close();
+ this._connection.asyncClose();
return true;
}
}
diff --git a/components/zotero-autocomplete.js b/components/zotero-autocomplete.js
@@ -223,37 +223,8 @@ ZoteroAutoComplete.prototype.startSearch = function(searchString, searchParams,
statement = this._zotero.DB.getStatement(sql, sqlParams);
}
- // Disable asynchronous until we figure out the hangs
- if (true) {
- var rows = this._zotero.DB.query(sql, sqlParams);
-
- if (resultsCallback) {
- resultsCallback(rows);
- }
-
- var results = [];
- var comments = [];
- for each(var row in rows) {
- results.push(row.val);
- let comment = row.comment;
- if (comment) {
- comments.push(comment);
- }
- }
- this.updateResults(results, comments);
- return;
- }
-
var self = this;
- this._zotero.DB._connection.setProgressHandler(5000, {
- onProgress: function (connection) {
- if (self._cancelled) {
- return true;
- }
- }
- });
-
this.pendingStatement = statement.executeAsync({
handleResult: function (storageResultSet) {
self._zotero.debug("Handling autocomplete results");
@@ -282,7 +253,7 @@ ZoteroAutoComplete.prototype.startSearch = function(searchString, searchParams,
},
handleError: function (e) {
- //Components.utils.reportError(e.message);
+ Components.utils.reportError(e.message);
},
handleCompletion: function (reason) {
@@ -352,10 +323,7 @@ ZoteroAutoComplete.prototype.updateResults = function (results, comments, ongoin
ZoteroAutoComplete.prototype.stopSearch = function(){
if (this.pendingStatement) {
this._zotero.debug('Stopping autocomplete search');
- // This appears to take as long as letting the query complete,
- // so we flag instead and abort from the progress handler
- //this.pendingStatement.cancel();
- this._cancelled = true;
+ this.pendingStatement.cancel();
}
}