summaryrefslogtreecommitdiff
path: root/plugins/Popup/src/popup_thread.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-11-24 14:19:23 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-11-24 14:19:23 +0000
commit5f3e3abd23f5ec503976885a073aae2c2a276ade (patch)
treedc4d38b0fd2accd1edf333646b9dcd084efce67c /plugins/Popup/src/popup_thread.cpp
parent5f5679475c4817314d5211e7f9714de0fea3efe3 (diff)
- 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
Diffstat (limited to 'plugins/Popup/src/popup_thread.cpp')
-rw-r--r--plugins/Popup/src/popup_thread.cpp21
1 files changed, 7 insertions, 14 deletions
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<PopupWnd2> 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];