From d575132cdc94cf476fee70859aa673a31aba3ea4 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Tue, 1 Mar 2016 08:34:15 +0000 Subject: dbx_lmdb: temporary crutch for fix events overwriting git-svn-id: http://svn.miranda-ng.org/main/trunk@16381 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dbx_mdb/src/dbcontacts.cpp | 4 +++- plugins/Dbx_mdb/src/dbevents.cpp | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'plugins/Dbx_mdb/src') diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp index 1ca1230f41..9b4775990c 100644 --- a/plugins/Dbx_mdb/src/dbcontacts.cpp +++ b/plugins/Dbx_mdb/src/dbcontacts.cpp @@ -339,9 +339,11 @@ void CDbxMdb::FillContacts() DBCachedContact *cc = arContacts[i]; CheckProto(cc, ""); - m_dwMaxContactId = cc->contactID+1; + m_dwMaxContactId = max(m_dwMaxContactId, cc->contactID+1); m_contactCount++; + m_dwMaxEventId = max(m_dwMaxEventId, FindLastEvent(cc->contactID) + 1); + DBVARIANT dbv; dbv.type = DBVT_DWORD; cc->nSubs = (0 != GetContactSetting(cc->contactID, META_PROTO, "NumContacts", &dbv)) ? -1 : dbv.dVal; if (cc->nSubs != -1) { diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp index d8ea2607a2..2e22931c47 100644 --- a/plugins/Dbx_mdb/src/dbevents.cpp +++ b/plugins/Dbx_mdb/src/dbevents.cpp @@ -249,15 +249,18 @@ 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); - while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) { - DBEvent *dbe = (DBEvent*)data.mv_data; - if (dbe->contactID != cc->contactID) - break; - if (!dbe->markedRead()) { - cc->dbc.dwFirstUnread = key2.dwEventId; - cc->dbc.tsFirstUnread = key2.ts; - return; + if (mdb_cursor_get(cursor, &key, &data, MDB_SET) == MDB_SUCCESS) + { + while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) + { + DBEvent *dbe = (DBEvent*)data.mv_data; + if (dbe->contactID != cc->contactID) + break; + if (!dbe->markedRead()) { + cc->dbc.dwFirstUnread = key2.dwEventId; + cc->dbc.tsFirstUnread = key2.ts; + return; + } } } -- cgit v1.2.3