diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-21 18:06:27 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-21 18:09:19 +0300 |
commit | f7001757a832e948645713a94739f66b07d5f2c1 (patch) | |
tree | 8accc928f2eadf5940a336f9be639b3f27e921a6 | |
parent | 6119b7865f7890d9bfc627d35d8e1262c2690e9c (diff) |
DATABASELINK::Unload method replaced with the virtual destructor of MDatabaseCommon
-rw-r--r-- | include/m_db_int.h | 15 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 130990 -> 130990 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 126498 -> 126498 bytes | |||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.cpp | 2 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/init.cpp | 9 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.cpp | 1 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/init.cpp | 10 | ||||
-rw-r--r-- | plugins/Import/src/dbrw/dbrw.cpp | 11 | ||||
-rw-r--r-- | plugins/Import/src/import.cpp | 5 | ||||
-rw-r--r-- | src/mir_app/src/database.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 4 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 4 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 4 | ||||
-rw-r--r-- | src/mir_app/src/newplugins.cpp | 2 |
14 files changed, 24 insertions, 49 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h index 0a6aa6ddb5..fa3bf15c43 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -139,14 +139,14 @@ protected: LIST<char> m_lResidentSettings;
protected:
- MDatabaseCommon();
- ~MDatabaseCommon();
-
int CheckProto(DBCachedContact *cc, const char *proto);
STDMETHOD_(BOOL, GetContactSettingWorker)(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic) PURE;
public:
+ MDatabaseCommon();
+ virtual ~MDatabaseCommon();
+
STDMETHODIMP_(BOOL) DeleteModule(MCONTACT contactID, LPCSTR szModule);
STDMETHODIMP_(MCONTACT) FindFirstContact(const char *szProto = nullptr);
@@ -240,14 +240,7 @@ struct DATABASELINK which is a PLUGINLINK structure
Returns: 0 on success, nonzero on failure
*/
- MIDatabase* (*Load)(const wchar_t *profile, BOOL bReadOnly);
-
- /*
- Affect: The database plugin should shutdown, unloading things from the core and freeing internal structures
- Returns: 0 on success, nonzero on failure
- Note: Unload() might be called even if Load(void) was never called, wasLoaded is set to 1 if Load(void) was ever called.
- */
- int (*Unload)(MIDatabase*);
+ MDatabaseCommon* (*Load)(const wchar_t *profile, BOOL bReadOnly);
/*
Returns a pointer to the database checker or NULL if a database doesn't support checking
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 6b984b4429..8dcb78e19a 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 85df6fe22f..52e98ecac3 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp index dc775b82b1..be36e4bdd7 100644 --- a/plugins/Db3x_mmap/src/dbintf.cpp +++ b/plugins/Db3x_mmap/src/dbintf.cpp @@ -59,6 +59,8 @@ CDb3Mmap::CDb3Mmap(const wchar_t *tszFileName, int iMode) : CDb3Mmap::~CDb3Mmap()
{
+ g_Dbs.remove(this);
+
// destroy modules
HeapDestroy(m_hModHeap);
diff --git a/plugins/Db3x_mmap/src/init.cpp b/plugins/Db3x_mmap/src/init.cpp index 21feb9ed49..a452a43321 100644 --- a/plugins/Db3x_mmap/src/init.cpp +++ b/plugins/Db3x_mmap/src/init.cpp @@ -67,6 +67,7 @@ static int grokHeader(const wchar_t *profile) // returns 0 if all the APIs are injected otherwise, 1
static MIDatabase* LoadDatabase(const wchar_t *profile, BOOL bReadOnly)
+static MDatabaseCommon* LoadDatabase(const wchar_t *profile, BOOL bReadOnly)
{
// set the memory, lists & UTF8 manager
mir_getLP(&pluginInfo);
@@ -79,13 +80,6 @@ static MIDatabase* LoadDatabase(const wchar_t *profile, BOOL bReadOnly) return db.release();
}
-static int UnloadDatabase(MIDatabase *db)
-{
- g_Dbs.remove((CDb3Mmap*)db);
- delete (CDb3Mmap*)db;
- return 0;
-}
-
MIDatabaseChecker* CheckDb(const wchar_t *profile, int *error)
{
std::auto_ptr<CDb3Mmap> db(new CDb3Mmap(profile, DBMODE_READONLY));
@@ -108,7 +102,6 @@ static DATABASELINK dblink = makeDatabase,
grokHeader,
LoadDatabase,
- UnloadDatabase,
CheckDb
};
diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp index e74f266248..e9d0b33ad9 100644 --- a/plugins/Dbx_mdbx/src/dbintf.cpp +++ b/plugins/Dbx_mdbx/src/dbintf.cpp @@ -39,6 +39,7 @@ CDbxMDBX::CDbxMDBX(const TCHAR *tszFileName, int iMode) : CDbxMDBX::~CDbxMDBX()
{
+ g_Dbs.remove(this);
mdbx_env_close(m_env);
DestroyServiceFunction(hService);
diff --git a/plugins/Dbx_mdbx/src/init.cpp b/plugins/Dbx_mdbx/src/init.cpp index bfb04f23ae..3e7153e6db 100644 --- a/plugins/Dbx_mdbx/src/init.cpp +++ b/plugins/Dbx_mdbx/src/init.cpp @@ -62,7 +62,7 @@ static int grokHeader(const TCHAR *profile) }
// returns 0 if all the APIs are injected otherwise, 1
-static MIDatabase* LoadDatabase(const TCHAR *profile, BOOL bReadOnly)
+static MDatabaseCommon* LoadDatabase(const TCHAR *profile, BOOL bReadOnly)
{
// set the memory, lists & UTF8 manager
mir_getLP(&pluginInfo);
@@ -75,13 +75,6 @@ static MIDatabase* LoadDatabase(const TCHAR *profile, BOOL bReadOnly) return db.release();
}
-static int UnloadDatabase(MIDatabase *db)
-{
- g_Dbs.remove((CDbxMDBX*)db);
- delete (CDbxMDBX*)db;
- return 0;
-}
-
MIDatabaseChecker* CheckDb(const TCHAR *profile, int *error)
{
std::unique_ptr<CDbxMDBX> db(new CDbxMDBX(profile, DBMODE_READONLY));
@@ -101,7 +94,6 @@ static DATABASELINK dblink = makeDatabase,
grokHeader,
LoadDatabase,
- UnloadDatabase,
CheckDb
};
diff --git a/plugins/Import/src/dbrw/dbrw.cpp b/plugins/Import/src/dbrw/dbrw.cpp index 728fafe9ff..b5ed672bdb 100644 --- a/plugins/Import/src/dbrw/dbrw.cpp +++ b/plugins/Import/src/dbrw/dbrw.cpp @@ -77,19 +77,13 @@ static int dbrw_grokHeader(const wchar_t *profile) return rc; } -static MIDatabase* dbrw_Load(const wchar_t *profile, BOOL) +static MDatabaseCommon* dbrw_Load(const wchar_t *profile, BOOL) { CDbxSQLite *db = new CDbxSQLite(); db->Open(profile); return db; } -static int dbrw_Unload(MIDatabase *db) -{ - delete (CDbxSQLite*)db; - return 0; -} - static DATABASELINK dblink = { sizeof(DATABASELINK), @@ -97,8 +91,7 @@ static DATABASELINK dblink = L"dbx SQLite driver", dbrw_makeDatabase, dbrw_grokHeader, - dbrw_Load, - dbrw_Unload + dbrw_Load }; void RegisterDbrw() diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 7a133ae62b..76ff58be8e 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -68,7 +68,8 @@ static LIST<DBCachedContact> arMetas(10); static HWND hdlgProgress;
static DWORD nDupes, nContactsCount, nMessagesCount, nGroupsCount, nSkippedEvents, nSkippedContacts;
-static MIDatabase *srcDb, *dstDb;
+static MDatabaseCommon *srcDb;
+static MIDatabase *dstDb;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1090,7 +1091,7 @@ void MirandaImport(HWND hdlg) dstDb->SetCacheSafetyMode(TRUE);
// Clean up before exit
- dblink->Unload(srcDb);
+ delete srcDb;
// Stop timer
dwTimer = time(nullptr) - dwTimer;
diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp index 1e02f0d009..b3f5f621e0 100644 --- a/src/mir_app/src/database.cpp +++ b/src/mir_app/src/database.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
#include "profilemanager.h"
-MIDatabase *currDb = nullptr;
+MDatabaseCommon *currDb = nullptr;
DATABASELINK *currDblink = nullptr;
// contains the location of mirandaboot.ini
@@ -400,7 +400,7 @@ int tryOpenDatabase(const wchar_t *tszProfile) }
// try to load database
- MIDatabase *pDb = it->Load(tszProfile, FALSE);
+ MDatabaseCommon *pDb = it->Load(tszProfile, FALSE);
if (pDb == nullptr)
return EGROKPRF_CANTREAD;
@@ -423,7 +423,7 @@ static int tryCreateDatabase(const wchar_t *ptszProfile) int err = p->makeDatabase(tszProfile);
if (err == ERROR_SUCCESS) {
g_bDbCreated = true;
- MIDatabase *pDb = p->Load(tszProfile, FALSE);
+ MDatabaseCommon *pDb = p->Load(tszProfile, FALSE);
if (pDb == nullptr) // driver was found but smth went wrong
return EGROKPRF_CANTREAD;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index fc95a820d8..ac28a88653 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -449,12 +449,12 @@ Skin_PlaySound @462 Skin_PlaySoundFile @463
Clist_SetStatusMode @464
??0CProtoIntDlgBase@@QAE@$$QAV0@@Z @465 NONAME
-??0MDatabaseCommon@@IAE@XZ @466 NONAME
+??0MDatabaseCommon@@QAE@XZ @466 NONAME
??0MDatabaseCommon@@QAE@ABV0@@Z @468 NONAME
??0MIDatabase@@QAE@$$QAU0@@Z @469 NONAME
??0MIDatabase@@QAE@ABU0@@Z @470 NONAME
??0MIDatabase@@QAE@XZ @471 NONAME
-??1MDatabaseCommon@@IAE@XZ @473 NONAME
+??1MDatabaseCommon@@UAE@XZ @472 NONAME
??4CProtoIntDlgBase@@QAEAAV0@$$QAV0@@Z @474 NONAME
??4MDatabaseCommon@@QAEAAV0@ABV0@@Z @476 NONAME
??4MIDatabase@@QAEAAU0@$$QAU0@@Z @477 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 45f671088e..6f4d79842a 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -449,12 +449,12 @@ Skin_PlaySound @462 Skin_PlaySoundFile @463
Clist_SetStatusMode @464
??0CProtoIntDlgBase@@QEAA@$$QEAV0@@Z @465 NONAME
-??0MDatabaseCommon@@IEAA@XZ @466 NONAME
+??0MDatabaseCommon@@QEAA@XZ @466 NONAME
??0MDatabaseCommon@@QEAA@AEBV0@@Z @468 NONAME
??0MIDatabase@@QEAA@$$QEAU0@@Z @469 NONAME
??0MIDatabase@@QEAA@AEBU0@@Z @470 NONAME
??0MIDatabase@@QEAA@XZ @471 NONAME
-??1MDatabaseCommon@@IEAA@XZ @473 NONAME
+??1MDatabaseCommon@@UEAA@XZ @472 NONAME
??4CProtoIntDlgBase@@QEAAAEAV0@$$QEAV0@@Z @474 NONAME
??4MDatabaseCommon@@QEAAAEAV0@AEBV0@@Z @476 NONAME
??4MIDatabase@@QEAAAEAU0@$$QEAU0@@Z @477 NONAME
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index bb06f8ae02..5d54d49e57 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -54,8 +54,8 @@ extern struct CHAT_MANAGER chatApi; /**** database.cpp *********************************************************************/
-extern MIDatabase* currDb;
-extern DATABASELINK* currDblink;
+extern MDatabaseCommon *currDb;
+extern DATABASELINK *currDblink;
extern LIST<DATABASELINK> arDbPlugins;
int InitIni(void);
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 3dbd984dfa..6c8a59924e 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -866,7 +866,7 @@ void UnloadDatabase(void) {
if (currDb != nullptr) {
db_setCurrent(nullptr);
- currDblink->Unload(currDb);
+ delete currDb;
currDb = nullptr;
currDblink = nullptr;
}
|