From 5f3e3abd23f5ec503976885a073aae2c2a276ade Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 24 Nov 2014 14:19:23 +0000 Subject: - fix for thread control in Popup+; - fix for a very specific crash on exit in MTextControl; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@11048 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Popup/src/popup_thread.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'plugins/Popup/src/popup_thread.cpp') diff --git a/plugins/Popup/src/popup_thread.cpp b/plugins/Popup/src/popup_thread.cpp index cede4d0a00..2c34d7e610 100644 --- a/plugins/Popup/src/popup_thread.cpp +++ b/plugins/Popup/src/popup_thread.cpp @@ -28,10 +28,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // globals static int gIdleRequests = 0; static bool gTerminating = false; -static HANDLE hThreadMutex = NULL; static HWND gHwndManager = 0; static int gLockCount = 0; static volatile int nPopups = 0; +static HANDLE hThread = 0; static LIST popupList(3); @@ -203,15 +203,8 @@ static LRESULT CALLBACK PopupThreadManagerWndProc(HWND hwnd, UINT message, WPARA } // thread func -static void __cdecl PopupThread(void *arg) +static unsigned __stdcall PopupThread(void *arg) { - // grab the mutex - if ( WaitForSingleObject(hThreadMutex, INFINITE) != WAIT_OBJECT_0) { - // other thread is already running - _endthread(); - return; - } - // Create manager window DWORD err; WNDCLASSEX wcl; @@ -245,7 +238,7 @@ static void __cdecl PopupThread(void *arg) } DestroyWindow(gHwndManager); gHwndManager = NULL; - ReleaseMutex(hThreadMutex); + return 0; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -253,8 +246,8 @@ static void __cdecl PopupThread(void *arg) void LoadPopupThread() { - hThreadMutex = CreateMutex(NULL, FALSE, NULL); - mir_forkthread(PopupThread, NULL); + unsigned threadId; + hThread = mir_forkthreadex(PopupThread, NULL, &threadId); } void StopPopupThread() @@ -265,8 +258,8 @@ void StopPopupThread() void UnloadPopupThread() { // We won't waint for thread to exit, Miranda's thread unsind mechanism will do that for us. - WaitForSingleObject(hThreadMutex, INFINITE); - CloseHandle(hThreadMutex); + WaitForSingleObject(hThread, INFINITE); + CloseHandle(hThread); for (int i=0; i < popupList.getCount(); ++i) delete popupList[i]; -- cgit v1.2.3