diff options
author | George Hazan <george.hazan@gmail.com> | 2023-11-04 19:45:24 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-11-04 19:45:24 +0300 |
commit | eb20cc93c014794923d75aafa54471e6fcf36da2 (patch) | |
tree | 937ec10fede8ead4087d8198a5ff3c0ee807fe3d /plugins | |
parent | f1c4d08896d6bda7c89f7145f61f724513888b77 (diff) |
better implementation of #3782
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Dbx_sqlite/src/dbintf.cpp | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/plugins/Dbx_sqlite/src/dbintf.cpp b/plugins/Dbx_sqlite/src/dbintf.cpp index 5d663be534..b5e305c755 100644 --- a/plugins/Dbx_sqlite/src/dbintf.cpp +++ b/plugins/Dbx_sqlite/src/dbintf.cpp @@ -80,14 +80,31 @@ int CDbxSQLite::Create() #define CURRVER 5
-static INT_PTR CALLBACK MsbBoxWndProc(HWND, UINT uMsg, WPARAM, LPARAM)
+static bool g_bConversionOver = false;
+
+static INT_PTR CALLBACK MsbBoxWndProc(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM)
{
- if (uMsg == WM_INITDIALOG)
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ SetForegroundWindow(hwndDlg);
+ SetTimer(hwndDlg, 1, 50, 0);
return TRUE;
+ case WM_TIMER:
+ if (g_bConversionOver)
+ EndDialog(hwndDlg, 1);
+ break;
+ }
+
return FALSE;
}
+static unsigned CALLBACK MsgBoxThread(void *)
+{
+ DialogBoxW(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MSGBOX), 0, MsbBoxWndProc);
+ return 0;
+}
+
void CDbxSQLite::CheckConversion()
{
DBVARIANT dbv = { DBVT_BYTE };
@@ -97,9 +114,8 @@ void CDbxSQLite::CheckConversion() if (dbv.bVal >= CURRVER)
return;
- HWND hwndMsgBox = CreateDialogW(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MSGBOX), 0, MsbBoxWndProc);
- ShowWindow(hwndMsgBox, SW_NORMAL);
- SetForegroundWindow(hwndMsgBox);
+ UINT tid;
+ mir_forkthreadex(MsgBoxThread, 0, &tid);
if (dbv.bVal < 1) {
int rc = sqlite3_exec(m_db, "ALTER TABLE events ADD COLUMN is_read INTEGER NOT NULL DEFAULT 0;", 0, 0, 0);
@@ -166,14 +182,13 @@ void CDbxSQLite::CheckConversion() rc = sqlite3_exec(m_db, "INSERT INTO tmp SELECT * FROM events_srt;", 0, 0, 0);
logError(rc, __FILE__, __LINE__);
- if (rc != 0)
- return;
-
- rc = sqlite3_exec(m_db, "DROP TABLE events_srt;", 0, 0, 0);
- logError(rc, __FILE__, __LINE__);
+ if (rc == 0) {
+ rc = sqlite3_exec(m_db, "DROP TABLE events_srt;", 0, 0, 0);
+ logError(rc, __FILE__, __LINE__);
- rc = sqlite3_exec(m_db, "ALTER TABLE tmp RENAME TO events_srt;", 0, 0, 0);
- logError(rc, __FILE__, __LINE__);
+ rc = sqlite3_exec(m_db, "ALTER TABLE tmp RENAME TO events_srt;", 0, 0, 0);
+ logError(rc, __FILE__, __LINE__);
+ }
}
if (dbv.bVal < 5) {
@@ -187,7 +202,7 @@ void CDbxSQLite::CheckConversion() dbv.bVal = CURRVER;
WriteContactSetting(0, "Compatibility", "Sqlite", &dbv);
- DestroyWindow(hwndMsgBox);
+ g_bConversionOver = true;
}
/////////////////////////////////////////////////////////////////////////////////////////
|