summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Clist_modern/src')
-rw-r--r--plugins/Clist_modern/src/modern_awaymsg.cpp11
-rw-r--r--plugins/Clist_modern/src/modern_cluiframes.cpp27
-rw-r--r--plugins/Clist_modern/src/modern_gettextasync.cpp94
3 files changed, 55 insertions, 77 deletions
diff --git a/plugins/Clist_modern/src/modern_awaymsg.cpp b/plugins/Clist_modern/src/modern_awaymsg.cpp
index 34dc4ad51c..a03e61bec2 100644
--- a/plugins/Clist_modern/src/modern_awaymsg.cpp
+++ b/plugins/Clist_modern/src/modern_awaymsg.cpp
@@ -189,10 +189,8 @@ static int amThreadProc(HWND hwnd)
BOOL amWakeThread()
{
- if (hamProcessEvent && g_dwAwayMsgThreadID)
- {
+ if (hamProcessEvent && g_dwAwayMsgThreadID) {
SetEvent(hamProcessEvent);
-
return TRUE;
}
@@ -224,9 +222,10 @@ void InitAwayMsgModule()
void UninitAwayMsgModule()
{
SetEvent(hamProcessEvent);
+
+ while (g_dwAwayMsgThreadID)
+ SleepEx(50, TRUE);
+
CloseHandle(hamProcessEvent);
- amlock;
- while (amGetCurrentChain());
- amunlock;
DeleteCriticalSection(&amLockChain);
}
diff --git a/plugins/Clist_modern/src/modern_cluiframes.cpp b/plugins/Clist_modern/src/modern_cluiframes.cpp
index 55822c76be..2c7a1de338 100644
--- a/plugins/Clist_modern/src/modern_cluiframes.cpp
+++ b/plugins/Clist_modern/src/modern_cluiframes.cpp
@@ -69,20 +69,9 @@ static int _iNextFrameId = 100;
static HFONT _hTitleBarFont = NULL;
// menus
-static HGENMENU _hmiVisible = (HGENMENU)-1;
-static HGENMENU _hmiTBVisible = (HGENMENU)-1;
-static HGENMENU _hmiLock = (HGENMENU)-1;
-static HGENMENU _hmiColl = (HGENMENU)-1;
-static HGENMENU _hmiFloating = (HGENMENU)-1;
-static HGENMENU _hmiAlignRoot = (HGENMENU)-1;
-static HGENMENU _hmiAlignTop = (HGENMENU)-1;
-static HGENMENU _hmiAlignClient = (HGENMENU)-1;
-static HGENMENU _hmiAlignBottom = (HGENMENU)-1;
-static HGENMENU _hmiPosRoot = (HGENMENU)-1;
-static HGENMENU _hmiPosUp = (HGENMENU)-1;
-static HGENMENU _hmiPosDown = (HGENMENU)-1;
-static HGENMENU _hmiBorder = (HGENMENU)-1;
-static HGENMENU _hmiRoot = (HGENMENU)-1;
+static HGENMENU _hmiVisible, _hmiTBVisible, _hmiLock, _hmiColl;
+static HGENMENU _hmiFloating, _hmiAlignRoot, _hmiAlignTop, _hmiAlignClient, _hmiAlignBottom;
+static HGENMENU _hmiPosRoot, _hmiPosUp, _hmiPosDown, _hmiBorder, _hmiRoot;
// others
static int _nContactListHeight = 0;
@@ -3913,7 +3902,6 @@ static int _us_DoSetFrameFloat(WPARAM wParam,LPARAM lParam)
return 0;
}
-
int CLUIFrameOnModulesLoad(WPARAM wParam,LPARAM lParam)
{
/* HOOK */
@@ -3921,11 +3909,14 @@ int CLUIFrameOnModulesLoad(WPARAM wParam,LPARAM lParam)
CLUIFramesCreateMenuForFrame(-1,-1,000010000, Menu_AddContextFrameMenuItem);
return 0;
}
+
int CLUIFrameOnModulesUnload(WPARAM wParam,LPARAM lParam)
{
- //
- //if (MirandaExiting()) return 0;
- if ( !_hmiVisible) return 0;
+ g_CluiData.bSTATE = STATE_PREPEARETOEXIT;
+
+ if ( !_hmiVisible)
+ return 0;
+
CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, (LPARAM)_hmiVisible, 1 );
CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, (LPARAM)_hmiTBVisible, 1 );
CallService( MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, (LPARAM)_hmiLock, 1 );
diff --git a/plugins/Clist_modern/src/modern_gettextasync.cpp b/plugins/Clist_modern/src/modern_gettextasync.cpp
index f73bb8cee8..7ec2ca1c3c 100644
--- a/plugins/Clist_modern/src/modern_gettextasync.cpp
+++ b/plugins/Clist_modern/src/modern_gettextasync.cpp
@@ -78,62 +78,50 @@ static BOOL gtaGetItem(GTACHAINITEM * mpChain)
static int gtaThreadProc(void * lpParam)
{
- BOOL exit = FALSE;
HWND hwnd = pcli->hwndContactList;
struct SHORTDATA data = {0};
- struct SHORTDATA * dat;
- while (!MirandaExiting())
- {
+ while (!MirandaExiting()) {
Sync(CLUI_SyncGetShortData,(WPARAM)pcli->hwndContactTree,(LPARAM)&data);
- do
- {
- if ( !MirandaExiting())
- SleepEx(0, TRUE); //1000 contacts per second
- if (MirandaExiting())
- {
+ while (true) {
+ if (MirandaExiting()) {
+ g_dwGetTextAsyncThreadID = 0;
+ return 0;
+ }
+ SleepEx(0, TRUE); //1000 contacts per second
+
+ GTACHAINITEM mpChain = {0};
+ struct SHORTDATA dat2 = {0};
+ if ( !gtaGetItem(&mpChain))
+ break;
+
+ SHORTDATA *dat;
+ if (mpChain.dat == NULL || (!IsBadReadPtr(mpChain.dat,sizeof(mpChain.dat)) && mpChain.dat->hWnd == data.hWnd))
+ dat = &data;
+ else {
+ Sync(CLUI_SyncGetShortData,(WPARAM)mpChain.dat->hWnd,(LPARAM)&dat2);
+ dat = &dat2;
+ }
+ if ( MirandaExiting()) {
g_dwGetTextAsyncThreadID = 0;
return 0;
}
- else
- {
- GTACHAINITEM mpChain = {0};
- struct SHORTDATA dat2 = {0};
- if ( !gtaGetItem(&mpChain)) break;
- if (mpChain.dat == NULL || (!IsBadReadPtr(mpChain.dat,sizeof(mpChain.dat)) && mpChain.dat->hWnd == data.hWnd)) dat = &data;
- else
- {
- Sync(CLUI_SyncGetShortData,(WPARAM)mpChain.dat->hWnd,(LPARAM)&dat2);
- dat = &dat2;
- }
- if ( !MirandaExiting())
- {
- ClcCacheEntry cacheEntry;
- memset( &cacheEntry, 0, sizeof(cacheEntry));
- cacheEntry.hContact = mpChain.hContact;
- if ( !Sync(CLUI_SyncGetPDNCE, (WPARAM) 0, (LPARAM)&cacheEntry))
- {
- if ( !MirandaExiting())
- Cache_GetSecondLineText(dat, &cacheEntry);
- if ( !MirandaExiting())
- Cache_GetThirdLineText(dat, &cacheEntry);
- if ( !MirandaExiting())
- Sync(CLUI_SyncSetPDNCE, (WPARAM) CCI_LINES,(LPARAM)&cacheEntry);
- CListSettings_FreeCacheItemData(&cacheEntry);
- }
- }
- else
- {
- g_dwGetTextAsyncThreadID = 0;
- return 0;
- }
- KillTimer(dat->hWnd,TIMERID_INVALIDATE_FULL);
- CLUI_SafeSetTimer(dat->hWnd,TIMERID_INVALIDATE_FULL,500, NULL);
+
+ ClcCacheEntry cacheEntry;
+ memset(&cacheEntry, 0, sizeof(cacheEntry));
+ cacheEntry.hContact = mpChain.hContact;
+ if ( !Sync(CLUI_SyncGetPDNCE, (WPARAM) 0, (LPARAM)&cacheEntry)) {
+ Cache_GetSecondLineText(dat, &cacheEntry);
+ Cache_GetThirdLineText(dat, &cacheEntry);
+ Sync(CLUI_SyncSetPDNCE, (WPARAM) CCI_LINES,(LPARAM)&cacheEntry);
+ CListSettings_FreeCacheItemData(&cacheEntry);
}
+
+ KillTimer(dat->hWnd,TIMERID_INVALIDATE_FULL);
+ CLUI_SafeSetTimer(dat->hWnd,TIMERID_INVALIDATE_FULL,500, NULL);
}
- while (!exit);
- WaitForSingleObjectEx(hgtaWakeupEvent, INFINITE, FALSE );
+ WaitForSingleObjectEx(hgtaWakeupEvent, INFINITE, TRUE);
ResetEvent(hgtaWakeupEvent);
}
g_dwGetTextAsyncThreadID = 0;
@@ -142,10 +130,8 @@ static int gtaThreadProc(void * lpParam)
BOOL gtaWakeThread()
{
- if (hgtaWakeupEvent && g_dwGetTextAsyncThreadID)
- {
+ if (hgtaWakeupEvent && g_dwGetTextAsyncThreadID) {
SetEvent(hgtaWakeupEvent);
-
return TRUE;
}
@@ -176,15 +162,18 @@ int gtaAddRequest(ClcData *dat,ClcContact *contact,HANDLE hContact)
gtaunlock;
return FALSE;
}
+
void gtaRenewText(HANDLE hContact)
{
gtaAddRequest(NULL,NULL, hContact);
}
+
int gtaOnModulesUnload(WPARAM wParam,LPARAM lParam)
{
SetEvent(hgtaWakeupEvent);
return 0;
}
+
void InitCacheAsync()
{
InitializeCriticalSection(&gtaCS);
@@ -195,11 +184,10 @@ void InitCacheAsync()
void UninitCacheAsync()
{
- GTACHAINITEM mpChain;
SetEvent(hgtaWakeupEvent);
+ while(g_dwGetTextAsyncThreadID)
+ SleepEx(50, TRUE);
+
CloseHandle(hgtaWakeupEvent);
- gtalock;
- while(gtaGetItem(&mpChain));
- gtaunlock;
DeleteCriticalSection(&gtaCS);
}