Make nsAutoCompleteMdbResult::RemoveValueAt do a CompressCommit after removing the mork row, to avoid corruption at shutdown. Also CutAllColumns like the corresponding history method does. Bug 242207, r=brettw sr/a=mconnor
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@198574 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -227,8 +227,33 @@ nsAutoCompleteMdbResult::RemoveValueAt(PRInt32 aRowIndex, PRBool aRemoveFromDb)
|
||||
NS_ENSURE_TRUE(row, NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aRemoveFromDb && mTable && mEnv) {
|
||||
// TODO: share this code with nsGlobalHistory::RemovePageInternal(),
|
||||
// rather than duplicating it here.
|
||||
|
||||
nsIMdbPort *port = nsnull;
|
||||
mTable->GetPort(mEnv, &port); // note: doesn't addref
|
||||
|
||||
nsCOMPtr<nsIMdbStore> store = do_QueryInterface(port);
|
||||
NS_ENSURE_TRUE(store, NS_ERROR_FAILURE);
|
||||
|
||||
mdb_err err = mTable->CutRow(mEnv, row);
|
||||
NS_ENSURE_TRUE(!err, NS_ERROR_FAILURE);
|
||||
|
||||
row->CutAllColumns(mEnv);
|
||||
|
||||
// We must do a CompressCommit on the store now. If we don't,
|
||||
// mork can leave the file in an inconsistent state, which causes it to
|
||||
// be killed the next time it's opened.
|
||||
|
||||
nsCOMPtr<nsIMdbThumb> thumb;
|
||||
err = store->CompressCommit(mEnv, getter_AddRefs(thumb));
|
||||
if (err == 0) {
|
||||
mdb_count total, current;
|
||||
mdb_bool done, broken;
|
||||
do {
|
||||
err = thumb->DoMore(mEnv, &total, ¤t, &done, &broken);
|
||||
} while ((err == 0) && !broken && !done);
|
||||
}
|
||||
}
|
||||
|
||||
mResults.RemoveObjectAt(aRowIndex);
|
||||
|
||||
Reference in New Issue
Block a user