summaryrefslogtreecommitdiff
path: root/plugins/Popup
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
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')
-rw-r--r--plugins/Popup/src/main.cpp11
-rw-r--r--plugins/Popup/src/popup_thread.cpp21
-rw-r--r--plugins/Popup/src/popup_wnd2.cpp3
-rw-r--r--plugins/Popup/src/version.h16
4 files changed, 24 insertions, 27 deletions
diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp
index 3f97bf29f9..19a01e7224 100644
--- a/plugins/Popup/src/main.cpp
+++ b/plugins/Popup/src/main.cpp
@@ -319,7 +319,6 @@ MIRAPI PLUGININFOEX* MirandaPluginInfoEx(DWORD)
return &pluginInfoEx;
}
-//ME_SYSTEM_PRESHUTDOWN event
//called before the app goes into shutdown routine to make sure everyone is happy to exit
static int OkToExit(WPARAM, LPARAM)
{
@@ -328,6 +327,13 @@ static int OkToExit(WPARAM, LPARAM)
return 0;
}
+static int OnShutdown(WPARAM, LPARAM)
+{
+ UnloadPopupThread();
+ UnloadPopupWnd2();
+ return 0;
+}
+
//===== Load =====
//Initializes the services provided and the link to those needed
//Called when the plugin is loaded into Miranda
@@ -367,6 +373,7 @@ MIRAPI int Load(void)
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
HookEvent(ME_SYSTEM_PRESHUTDOWN, OkToExit);
+ HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown);
hbmNoAvatar = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_NOAVATAR));
@@ -437,8 +444,6 @@ MIRAPI int Unload(void)
mir_free(PopupOptions.Effect);
OptAdv_UnregisterVfx();
- UnloadPopupThread();
- UnloadPopupWnd2();
PopupHistoryUnload();
SrmmMenu_Unload();
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];
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp
index cb2b350861..70c6fa820a 100644
--- a/plugins/Popup/src/popup_wnd2.cpp
+++ b/plugins/Popup/src/popup_wnd2.cpp
@@ -51,7 +51,6 @@ LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
bool LoadPopupWnd2()
{
bool res = true;
- DWORD err;
WNDCLASSEX wcl;
wcl.cbSize = sizeof(wcl);
@@ -67,7 +66,7 @@ bool LoadPopupWnd2()
wcl.lpszClassName = _T(POPUP_WNDCLASS);
wcl.hIconSm = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
g_wndClass.cPopupWnd2 = RegisterClassEx(&wcl);
- err = GetLastError();
+ DWORD err = GetLastError();
if (!g_wndClass.cPopupWnd2) {
res = false;
TCHAR msg[1024];
diff --git a/plugins/Popup/src/version.h b/plugins/Popup/src/version.h
index 6651330150..445ddb4096 100644
--- a/plugins/Popup/src/version.h
+++ b/plugins/Popup/src/version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 2
-#define __MINOR_VERSION 1
-#define __RELEASE_NUM 1
-#define __BUILD_NUM 8
+#define __MAJOR_VERSION 2
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 9
#include <stdver.h>
#define __PLUGIN_NAME "Popup plus"
#define __FILENAME "Popup.dll"
-#define __DESCRIPTION "Provides popup notification services for different plugins."
-#define __AUTHOR "MPK, Merlin_de (Luca Santarelli, Victor Pavlychko)"
+#define __DESCRIPTION "Provides popup notification services for different plugins."
+#define __AUTHOR "MPK, Merlin_de (Luca Santarelli, Victor Pavlychko)"
#define __AUTHOREMAIL "mp-king@web.de"
-#define __AUTHORWEB "http://miranda-ng.org/p/Popup/"
-#define __COPYRIGHT "© 2002 Luca Santarelli, 2004-2007 Victor Pavlychko, 2010 MPK, Merlin_de"
+#define __AUTHORWEB "http://miranda-ng.org/p/Popup/"
+#define __COPYRIGHT "© 2002 Luca Santarelli, 2004-2007 Victor Pavlychko, 2010 MPK, Merlin_de"