From 60f69a369747444ced2209bcf19ab0a379acc681 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 27 Feb 2016 16:18:55 +0000 Subject: dbx_lmdb: one more contact deletion fix git-svn-id: http://svn.miranda-ng.org/main/trunk@16365 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dbx_mdb/src/dbcontacts.cpp | 15 ++++++++------- plugins/Dbx_mdb/src/dbevents.cpp | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'plugins/Dbx_mdb') diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp index b59e69fe47..1ca1230f41 100644 --- a/plugins/Dbx_mdb/src/dbcontacts.cpp +++ b/plugins/Dbx_mdb/src/dbcontacts.cpp @@ -115,7 +115,7 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID) events.remove(0); } } - {// this code not delete all settings + { DBSettingKey keyS = { contactID, 0 }; memset(keyS.szSettingName, 0, sizeof(keyS.szSettingName)); @@ -124,15 +124,16 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID) key.mv_size = sizeof(keyS); key.mv_data = &keyS; - mdb_cursor_get(cursor, &key, &data, MDB_SET); + mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE); - while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) + do { DBSettingKey *pKey = (DBSettingKey*)key.mv_data; if (pKey->dwContactID != contactID) break; mdb_cursor_del(cursor, 0); - } + } + while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS); txn.commit(); } @@ -202,14 +203,14 @@ void CDbxMdb::GatherContactHistory(MCONTACT hContact, LIST &list) txn_ptr_ro trnlck(m_txn); cursor_ptr_ro cursor(m_curEventsSort); - mdb_cursor_get(cursor, &key, &data, MDB_SET); - while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) { + mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE); + do { DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data; if (pKey->dwContactId != hContact) return; list.insert(new EventItem(pKey->ts, pKey->dwEventId)); - } + } while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS); } BOOL CDbxMdb::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp index bee0cffcc8..03bd186165 100644 --- a/plugins/Dbx_mdb/src/dbevents.cpp +++ b/plugins/Dbx_mdb/src/dbevents.cpp @@ -244,6 +244,7 @@ void CDbxMdb::FindNextUnread(const txn_ptr &txn, DBCachedContact *cc, DBEventSor MDB_val key = { sizeof(key2), &key2 }, data; key2.dwEventId++; + mdb_cursor_get(cursor, &key, &data, MDB_SET_KEY); while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) { DBEvent *dbe = (DBEvent*)data.mv_data; -- cgit v1.2.3