From d89ae362ba46d8885f0980e2af3bf142598c2d90 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 10 Apr 2018 19:07:55 +0300 Subject: fixes #1244 (Deleting subcontact history event leads to metacontact empty history event) --- plugins/Dbx_mdbx/src/dbevents.cpp | 15 +++++++++++---- plugins/Dbx_mdbx/src/version.h | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/Dbx_mdbx/src/dbevents.cpp b/plugins/Dbx_mdbx/src/dbevents.cpp index ad8d478b73..fa808b9d0d 100644 --- a/plugins/Dbx_mdbx/src/dbevents.cpp +++ b/plugins/Dbx_mdbx/src/dbevents.cpp @@ -160,8 +160,14 @@ STDMETHODIMP_(BOOL) CDbxMDBX::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) dbe = *(DBEvent*)data.iov_base; } + // if we removing the sub's event using metacontact's contactID + // we also need to remove this event from sub's history if (contactID != dbe.contactID) cc2 = m_cache->GetCachedContact(dbe.contactID); + // or, if we removing the sub's event using sub's contactID + // we also need to remove it from meta's history + else if (cc->IsSub()) + cc2 = m_cache->GetCachedContact(cc->parentID); { txn_ptr trnlck(StartTran()); @@ -172,13 +178,13 @@ STDMETHODIMP_(BOOL) CDbxMDBX::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) return 1; if (contactID != 0) { - key.iov_len = sizeof(MCONTACT); key.iov_base = &contactID; cc->dbc.dwEventCount--; if (cc->dbc.evFirstUnread == hDbEvent) FindNextUnread(trnlck, cc, key2); + MDBX_val keyc = { &contactID, sizeof(MCONTACT) }; data.iov_len = sizeof(DBContact); data.iov_base = &cc->dbc; - if (mdbx_put(trnlck, m_dbContacts, &key, &data, 0) != MDBX_SUCCESS) + if (mdbx_put(trnlck, m_dbContacts, &keyc, &data, 0) != MDBX_SUCCESS) return 1; } else { @@ -193,7 +199,7 @@ STDMETHODIMP_(BOOL) CDbxMDBX::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) } if (cc2) { - key2.hContact = dbe.contactID; + key2.hContact = cc2->contactID; if (mdbx_del(trnlck, m_dbEventsSort, &key, nullptr) != MDBX_SUCCESS) return 1; @@ -202,8 +208,9 @@ STDMETHODIMP_(BOOL) CDbxMDBX::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) if (cc2->dbc.evFirstUnread == hDbEvent) FindNextUnread(trnlck, cc2, key2); + MDBX_val keyc = { &cc2->contactID, sizeof(MCONTACT) }; data.iov_len = sizeof(DBContact); data.iov_base = &cc2->dbc; - if (mdbx_put(trnlck, m_dbContacts, &key, &data, 0) != MDBX_SUCCESS) + if (mdbx_put(trnlck, m_dbContacts, &keyc, &data, 0) != MDBX_SUCCESS) return 1; } diff --git a/plugins/Dbx_mdbx/src/version.h b/plugins/Dbx_mdbx/src/version.h index 094b434a85..ba74fc9109 100644 --- a/plugins/Dbx_mdbx/src/version.h +++ b/plugins/Dbx_mdbx/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 95 #define __RELEASE_NUM 8 -#define __BUILD_NUM 6 +#define __BUILD_NUM 7 #include -- cgit v1.2.3