From 1019387a8f6ccc087a113f138c5237146492a356 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 26 Jul 2018 21:40:50 +0300 Subject: fixes #1527 (Remove obsolete g_hMainThread and QueueUSerAPC from plugins) --- plugins/BasicHistory/src/BasicHistory.cpp | 6 ------ plugins/BasicHistory/src/Scheduler.cpp | 16 +++++++++------- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'plugins/BasicHistory/src') diff --git a/plugins/BasicHistory/src/BasicHistory.cpp b/plugins/BasicHistory/src/BasicHistory.cpp index a371fcdfa0..091d9b15d9 100644 --- a/plugins/BasicHistory/src/BasicHistory.cpp +++ b/plugins/BasicHistory/src/BasicHistory.cpp @@ -22,7 +22,6 @@ along with this program. If not, see . #define MS_HISTORY_EXECUTE_TASK "BasicHistory/ExecuteTask" HCURSOR hCurSplitNS, hCurSplitWE; -HANDLE g_hMainThread = nullptr; HANDLE *hEventIcons = nullptr; int iconsNum = 3; @@ -237,7 +236,6 @@ int ModulesLoaded(WPARAM, LPARAM) int CMPlugin::Load() { hTaskMainMenu = nullptr; - DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &g_hMainThread, 0, FALSE, DUPLICATE_SAME_ACCESS); hCurSplitNS = LoadCursor(nullptr, IDC_SIZENS); hCurSplitWE = LoadCursor(nullptr, IDC_SIZEWE); @@ -261,10 +259,6 @@ int CMPlugin::Load() int CMPlugin::Unload() { - if (g_hMainThread) - CloseHandle(g_hMainThread); - g_hMainThread = nullptr; - HistoryWindow::Deinit(); DestroyCursor(hCurSplitNS); diff --git a/plugins/BasicHistory/src/Scheduler.cpp b/plugins/BasicHistory/src/Scheduler.cpp index 26dfcb3fb2..57b93a97c8 100644 --- a/plugins/BasicHistory/src/Scheduler.cpp +++ b/plugins/BasicHistory/src/Scheduler.cpp @@ -22,8 +22,8 @@ along with this program. If not, see . #include "HistoryWindow.h" // Sorry for plain C implementation -#define MODULENAME "BasicHistory" -extern HANDLE g_hMainThread; +#define MODULENAME "BasicHistory" + bool bPopupsEnabled; bool DoTask(TaskOptions& to); bool IsValidTask(TaskOptions& to, std::list* top = nullptr, std::wstring* err = nullptr, std::wstring* errDescr = nullptr); @@ -217,7 +217,7 @@ bool IsValidTask(TaskOptions& to, std::list* top, std::wstring* err return true; } -static void CALLBACK DoRebuildEventsInMainAPCFunc(ULONG_PTR dwParam) +static INT_PTR CALLBACK DoRebuildEventsInMainAPCFunc(void *dwParam) { MCONTACT *contacts = (MCONTACT*)dwParam; size_t size = (size_t)contacts[0]; @@ -225,6 +225,7 @@ static void CALLBACK DoRebuildEventsInMainAPCFunc(ULONG_PTR dwParam) HistoryWindow::RebuildEvents(contacts[i]); delete[] contacts; + return 0; } bool DoTask(TaskOptions& to) @@ -416,7 +417,7 @@ bool DoTask(TaskOptions& to) for (std::list::iterator it = contactList.begin(); it != contactList.end(); ++it) pContacts[i++] = *it; - QueueUserAPC(DoRebuildEventsInMainAPCFunc, g_hMainThread, (ULONG_PTR)pContacts); + CallFunctionSync(DoRebuildEventsInMainAPCFunc, pContacts); } } @@ -788,11 +789,12 @@ bool GetNextExportTime(bool init, time_t now) return isExport; } -static void CALLBACK DoTaskFinishInMainAPCFunc(ULONG_PTR dwParam) +static INT_PTR CALLBACK DoTaskFinishInMainAPCFunc(void *param) { - wchar_t *item = (wchar_t*)dwParam; + wchar_t *item = (wchar_t*)param; MessageBox(nullptr, item, TranslateT("Task finished"), MB_OK | MB_ICONINFORMATION); delete[] item; + return 0; } bool ExecuteCurrentTask(time_t now) @@ -843,7 +845,7 @@ bool ExecuteCurrentTask(time_t now) mir_snwprintf(name, size, TranslateT("Task '%s' execution failed"), to.taskName.c_str()); else mir_snwprintf(name, size, TranslateT("Task '%s' finished successfully"), to.taskName.c_str()); - QueueUserAPC(DoTaskFinishInMainAPCFunc, g_hMainThread, (ULONG_PTR)name); + CallFunctionSync(DoTaskFinishInMainAPCFunc, name); } } } -- cgit v1.2.3