From 3f4a9293edf07c4e8f3cd6ecfba2de9ed8afbdb3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 12 Mar 2015 23:01:42 +0000 Subject: fix for the cursor scope git-svn-id: http://svn.miranda-ng.org/main/trunk@12392 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dbx_mdb/src/dbcontacts.cpp | 46 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp index 43296ff777..05d235c4e3 100644 --- a/plugins/Dbx_mdb/src/dbcontacts.cpp +++ b/plugins/Dbx_mdb/src/dbcontacts.cpp @@ -160,19 +160,20 @@ BOOL CDbxMdb::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) MDB_val key = { sizeof(keyVal), &keyVal }, key2 = { sizeof(insVal), &insVal }, data; txn_ptr trnlck(m_pMdbEnv); + { + cursor_ptr cursor(trnlck, m_dbEventsSort); + mdb_cursor_get(cursor, &key, &data, MDB_SET); + while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) { + DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data; + if (pKey->dwContactId != ccSub->contactID) + break; - cursor_ptr cursor(trnlck, m_dbEventsSort); - mdb_cursor_get(cursor, &key, &data, MDB_SET); - while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) { - DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data; - if (pKey->dwContactId != ccSub->contactID) - break; - - insVal.ts = pKey->ts; - insVal.dwEventId = pKey->dwEventId; - mdb_put(trnlck, m_dbEventsSort, &key2, &data, 0); + insVal.ts = pKey->ts; + insVal.dwEventId = pKey->dwEventId; + mdb_put(trnlck, m_dbEventsSort, &key2, &data, 0); - ccMeta->dbc.dwEventCount++; + ccMeta->dbc.dwEventCount++; + } } MDB_val keyc = { sizeof(int), &ccMeta->contactID }, datac = { sizeof(ccMeta->dbc), &ccMeta->dbc }; @@ -190,19 +191,20 @@ BOOL CDbxMdb::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) MDB_val key = { sizeof(keyVal), &keyVal }, key2 = { sizeof(delVal), &delVal }, data; txn_ptr trnlck(m_pMdbEnv); + { + cursor_ptr cursor(trnlck, m_dbEventsSort); + mdb_cursor_get(cursor, &key, &data, MDB_SET); + while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) { + DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data; + if (pKey->dwContactId != ccSub->contactID) + break; - cursor_ptr cursor(trnlck, m_dbEventsSort); - mdb_cursor_get(cursor, &key, &data, MDB_SET); - while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) { - DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data; - if (pKey->dwContactId != ccSub->contactID) - break; - - delVal.ts = pKey->ts; - delVal.dwEventId = pKey->dwEventId; - mdb_del(trnlck, m_dbEventsSort, &key2, &data); + delVal.ts = pKey->ts; + delVal.dwEventId = pKey->dwEventId; + mdb_del(trnlck, m_dbEventsSort, &key2, &data); - ccMeta->dbc.dwEventCount--; + ccMeta->dbc.dwEventCount--; + } } MDB_val keyc = { sizeof(int), &ccMeta->contactID }, datac = { sizeof(ccMeta->dbc), &ccMeta->dbc }; -- cgit v1.2.3