From cf9da90f48c5d8b415c449eb42434d4843610c5d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 19 Feb 2013 20:53:40 +0000 Subject: miranda hangs up when one of the standard modules is missing git-svn-id: http://svn.miranda-ng.org/main/trunk@3645 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/modern_awaymsg.cpp | 11 ++- plugins/Clist_modern/src/modern_cluiframes.cpp | 27 +++---- plugins/Clist_modern/src/modern_gettextasync.cpp | 94 +++++++++++------------- 3 files changed, 55 insertions(+), 77 deletions(-) (limited to 'plugins/Clist_modern') 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(>aCS); @@ -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(>aCS); } -- cgit v1.2.3