From 72348ec753695b71234631f4c358ca4505a1d737 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 16 Feb 2021 22:01:27 +0300 Subject: fixes #2745 (Dbx_sqlite: wrong behaviour when launching second Miranda with the same profile) --- plugins/Dbx_sqlite/src/main.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'plugins/Dbx_sqlite/src/main.cpp') diff --git a/plugins/Dbx_sqlite/src/main.cpp b/plugins/Dbx_sqlite/src/main.cpp index e3fe8b51d9..6c0f75b741 100644 --- a/plugins/Dbx_sqlite/src/main.cpp +++ b/plugins/Dbx_sqlite/src/main.cpp @@ -27,14 +27,38 @@ CMPlugin::CMPlugin() : ///////////////////////////////////////////////////////////////////////////////////////// +// returns 0 if the profile is created, EMKPRF* +static int makeDatabase(const wchar_t *profile) +{ + std::unique_ptr db(new CDbxSQLite(profile, false, false)); + return db->Create(); +} + +// returns 0 if the given profile has a valid header +static int grokHeader(const wchar_t *profile) +{ + std::unique_ptr db(new CDbxSQLite(profile, true, true)); + return db->Check(); +} + +// returns 0 if all the APIs are injected otherwise, 1 +static MDatabaseCommon* loadDatabase(const wchar_t *profile, BOOL bReadOnly) +{ + std::unique_ptr db(new CDbxSQLite(profile, bReadOnly, false)); + if (db->Load() != ERROR_SUCCESS) + return nullptr; + + return db.release(); +} + static DATABASELINK dblink = { MDB_CAPS_CREATE | MDB_CAPS_COMPACT, "dbx_sqlite", L"SQLite database driver", - &CDbxSQLite::Create, - &CDbxSQLite::Check, - &CDbxSQLite::Load, + makeDatabase, + grokHeader, + loadDatabase , }; STDMETHODIMP_(DATABASELINK *) CDbxSQLite::GetDriver() -- cgit v1.2.3