diff --git a/services/sync/modules/engines/forms.js b/services/sync/modules/engines/forms.js index 76a2a992f46f..03610ef5c0d7 100644 --- a/services/sync/modules/engines/forms.js +++ b/services/sync/modules/engines/forms.js @@ -79,6 +79,13 @@ let FormWrapper = { return this._stmts[query] = db.createAsyncStatement(query); }, + _finalize : function () { + for each (let stmt in FormWrapper._stmts) { + stmt.finalize(); + } + FormWrapper._stmts = {}; + }, + get _getAllEntriesStmt() { const query = "SELECT fieldname name, value FROM moz_formhistory " + @@ -270,6 +277,7 @@ function FormTracker(name) { Tracker.call(this, name); Svc.Obs.add("weave:engine:start-tracking", this); Svc.Obs.add("weave:engine:stop-tracking", this); + Svc.Obs.add("profile-change-teardown", this); } FormTracker.prototype = { __proto__: Tracker.prototype, @@ -320,6 +328,9 @@ FormTracker.prototype = { this.trackEntry(name, value); } break; + case "profile-change-teardown": + FormWrapper._finalize(); + break; } }, diff --git a/toolkit/components/satchel/nsFormHistory.js b/toolkit/components/satchel/nsFormHistory.js index cdacd67ac15b..6a1974665314 100644 --- a/toolkit/components/satchel/nsFormHistory.js +++ b/toolkit/components/satchel/nsFormHistory.js @@ -137,6 +137,7 @@ FormHistory.prototype = { this.messageManager.addMessageListener("FormHistory:FormSubmitEntries", this); // Add observers + Services.obs.addObserver(this, "profile-change-teardown", true); Services.obs.addObserver(this, "profile-before-change", true); Services.obs.addObserver(this, "idle-daily", true); Services.obs.addObserver(this, "formhistory-expire-now", true); @@ -402,6 +403,9 @@ FormHistory.prototype = { this.expireOldEntries(); break; case "profile-before-change": + // FIXME (bug 696486): close the connection in here. + break; + case "profile-change-teardown": this._dbFinalize(); break; default: @@ -870,7 +874,6 @@ FormHistory.prototype = { * Finalize all statements to allow closing the connection correctly. */ _dbFinalize : function FH__dbFinalize() { - // FIXME (bug 696486): close the connection in here. for each (let stmt in this.dbStmts) { stmt.finalize(); }