diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-30 19:30:44 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-30 19:30:44 +0000 |
commit | a6ce02772dde52fd7b1de9d4b7ba6949c8b2316f (patch) | |
tree | 40ab988463f4bda4d361c59acc3f4bd39f2aa2a5 | |
parent | 54b79c7733c3005937f5ad5cd68672c2397493fe (diff) |
minus critical section
git-svn-id: http://svn.miranda-ng.org/main/trunk@13311 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp | 4 | ||||
-rw-r--r-- | plugins/Clist_modern/src/hdr/modern_image_array.h | 2 | ||||
-rw-r--r-- | plugins/Clist_modern/src/hdr/modern_skinned_profile.h | 51 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_awaymsg.cpp | 4 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_image_array.cpp | 46 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_skinbutton.cpp | 14 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_skinengine.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_skinned_profile.cpp | 14 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_tbbutton.cpp | 2 |
9 files changed, 28 insertions, 111 deletions
diff --git a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp index 784e4ae2ed..53170369c0 100644 --- a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp @@ -61,7 +61,7 @@ static int _us_DoSetFramePaintProc(WPARAM wParam, LPARAM lParam); -static CRITICAL_SECTION _cluiFramesModuleCS = { 0 };
+static mir_cs _cluiFramesModuleCS;
static BOOL _cluiFramesModuleCSInitialized = FALSE;
static BOOL _fCluiFramesModuleNotStarted = TRUE;
static XPTHANDLE _hFrameTitleTheme = NULL;
@@ -3610,7 +3610,6 @@ int CLUIFrameOnModulesUnload(WPARAM, LPARAM) int LoadCLUIFramesModule(void)
{
- InitializeCriticalSection(&_cluiFramesModuleCS);
_cluiFramesModuleCSInitialized = TRUE;
WNDCLASS wndclass = { 0 };
@@ -3708,7 +3707,6 @@ int UnLoadCLUIFramesModule(void) DeleteObject(_hTitleBarFont);
_cluiFramesModuleCSInitialized = FALSE;
- DeleteCriticalSection(&_cluiFramesModuleCS);
return 0;
}
diff --git a/plugins/Clist_modern/src/hdr/modern_image_array.h b/plugins/Clist_modern/src/hdr/modern_image_array.h index e45b3c4fef..a5acd94588 100644 --- a/plugins/Clist_modern/src/hdr/modern_image_array.h +++ b/plugins/Clist_modern/src/hdr/modern_image_array.h @@ -52,7 +52,7 @@ struct IMAGE_ARRAY_DATA void * lpBits;
// CS
- CRITICAL_SECTION cs;
+ mir_cs cs;
// Array
IMAGE_ARRAY_DATA_NODE *nodes;
diff --git a/plugins/Clist_modern/src/hdr/modern_skinned_profile.h b/plugins/Clist_modern/src/hdr/modern_skinned_profile.h index 6da6e33821..87b4498313 100644 --- a/plugins/Clist_modern/src/hdr/modern_skinned_profile.h +++ b/plugins/Clist_modern/src/hdr/modern_skinned_profile.h @@ -47,55 +47,6 @@ public: };
-class CAutoCriticalSection
-{
-public:
- CAutoCriticalSection() //Init critical section here
- : _pLinkedCS(NULL)
- {
- InitializeCriticalSection(&_CS);
- _ifCSOwner = true;
- _ifLocked = false;
- }
- CAutoCriticalSection(CAutoCriticalSection& Locker, bool doLock = true)
- : _pLinkedCS(&Locker)
- {
- _ifCSOwner = false;
- _ifLocked = false;
- if (doLock)
- Lock();
- }
- ~CAutoCriticalSection() // Leave if auto locker, and destroy if not
- {
- if (_ifLocked)
- Unlock();
- if (_ifCSOwner)
- DeleteCriticalSection(&_CS);
- }
-
- void Lock() // Enter Section
- {
- if (_ifLocked) return;
- if (_ifCSOwner) EnterCriticalSection(&_CS);
- else _pLinkedCS->Lock();
- _ifLocked = true;
- return;
- }
- void Unlock() // Leave Section
- {
- if (!_ifLocked) return;
- if (_ifCSOwner) LeaveCriticalSection(&_CS);
- else _pLinkedCS->Unlock();
- _ifLocked = false;
- }
-
-private:
- CRITICAL_SECTION _CS;
- CAutoCriticalSection * _pLinkedCS;
- bool _ifCSOwner;
- bool _ifLocked;
-};
-
class ValueVariant
{
public:
@@ -225,7 +176,7 @@ private: ValueVariant* _GetValue(const char * szSection, const char * szKey);
- CAutoCriticalSection _Lock; // critical section to matable skinned profile access
+ mir_cs _Lock; // critical section to matable skinned profile access
public:
static CSkinnedProfile* SkinProfile() { return &_me; }
diff --git a/plugins/Clist_modern/src/modern_awaymsg.cpp b/plugins/Clist_modern/src/modern_awaymsg.cpp index 38b092d744..251217e4a0 100644 --- a/plugins/Clist_modern/src/modern_awaymsg.cpp +++ b/plugins/Clist_modern/src/modern_awaymsg.cpp @@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define AMASKPERIOD 3000
-static CRITICAL_SECTION amCS;
+static mir_cs amCS;
static LIST<void> amItems(10, PtrKeySortT);
static HANDLE hamProcessEvent = NULL;
@@ -159,7 +159,6 @@ void amRequestAwayMsg(MCONTACT hContact) void InitAwayMsgModule()
{
- InitializeCriticalSection(&amCS);
hamProcessEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
g_hAwayMsgThread = mir_forkthread(amThreadProc, 0);
}
@@ -172,5 +171,4 @@ void UninitAwayMsgModule() SleepEx(50, TRUE);
CloseHandle(hamProcessEvent);
- DeleteCriticalSection(&amCS);
}
diff --git a/plugins/Clist_modern/src/modern_image_array.cpp b/plugins/Clist_modern/src/modern_image_array.cpp index ada7a05d7a..020c58a25b 100644 --- a/plugins/Clist_modern/src/modern_image_array.cpp +++ b/plugins/Clist_modern/src/modern_image_array.cpp @@ -112,8 +112,6 @@ void ImageArray_Initialize(IMAGE_ARRAY_DATA *iad, BOOL width_based, int grow_ste iad->width = 0;
iad->height = 0;
- InitializeCriticalSection(&iad->cs);
-
iad->nodes = NULL;
iad->nodes_allocated_size = 0;
iad->nodes_size = 0;
@@ -140,8 +138,6 @@ HBITMAP ImageArray_Free(IMAGE_ARRAY_DATA *iad, BOOL keep_bitmap) iad->nodes_size = 0;
}
- DeleteCriticalSection(&iad->cs);
-
return iad->img;
}
@@ -183,7 +179,7 @@ int ImageArray_AddImage(IMAGE_ARRAY_DATA *iad, HBITMAP hBmp, int pos) if (hBmp == NULL)
return -1;
- EnterCriticalSection(&iad->cs);
+ mir_cslock lck(iad->cs);
if (pos < 0)
pos = iad->nodes_size;
@@ -198,10 +194,8 @@ int ImageArray_AddImage(IMAGE_ARRAY_DATA *iad, HBITMAP hBmp, int pos) }
// Get bounds
- if (!GetObject(hBmp, sizeof(BITMAP), &bm)) {
- LeaveCriticalSection(&iad->cs);
+ if (!GetObject(hBmp, sizeof(BITMAP), &bm))
return -1;
- }
if (iad->width_based) {
new_width = max(bm.bmWidth, iad->width);
@@ -214,15 +208,12 @@ int ImageArray_AddImage(IMAGE_ARRAY_DATA *iad, HBITMAP hBmp, int pos) // Alloc image
hNewBmp = ImageArray_CreateBitmapPoint(new_width, new_height, &(iad->lpBits));
- if (hNewBmp == NULL) {
- LeaveCriticalSection(&iad->cs);
+ if (hNewBmp == NULL)
return -1;
- }
// Alloc array
if (!ImageArray_Alloc(iad, iad->nodes_size + 1)) {
DeleteObject(hNewBmp);
- LeaveCriticalSection(&iad->cs);
return -1;
}
@@ -323,9 +314,6 @@ int ImageArray_AddImage(IMAGE_ARRAY_DATA *iad, HBITMAP hBmp, int pos) iad->width = new_width;
iad->height = new_height;
- // Finished it!
- LeaveCriticalSection(&iad->cs);
-
return pos;
}
@@ -349,13 +337,11 @@ BOOL ImageArray_ChangeImage(IMAGE_ARRAY_DATA *iad, HBITMAP hBmp, int pos) if (pos >= iad->nodes_size)
return FALSE;
- EnterCriticalSection(&iad->cs);
+ mir_cslock lck(iad->cs);
// Get bounds
- if (!GetObject(hBmp, sizeof(BITMAP), &bm)) {
- LeaveCriticalSection(&iad->cs);
+ if (!GetObject(hBmp, sizeof(BITMAP), &bm))
return FALSE;
- }
if (iad->width_based) {
new_width = max(bm.bmWidth, iad->width);
@@ -368,10 +354,8 @@ BOOL ImageArray_ChangeImage(IMAGE_ARRAY_DATA *iad, HBITMAP hBmp, int pos) // Alloc image
hNewBmp = ImageArray_CreateBitmapPoint(new_width, new_height, &(iad->lpBits));
- if (hNewBmp == NULL) {
- LeaveCriticalSection(&iad->cs);
+ if (hNewBmp == NULL)
return FALSE;
- }
// Move image...
@@ -465,9 +449,6 @@ BOOL ImageArray_ChangeImage(IMAGE_ARRAY_DATA *iad, HBITMAP hBmp, int pos) iad->width = new_width;
iad->height = new_height;
- // Finished it!
- LeaveCriticalSection(&iad->cs);
-
return pos;
}
@@ -486,7 +467,7 @@ BOOL ImageArray_RemoveImage(IMAGE_ARRAY_DATA *iad, int pos) if (pos >= iad->nodes_size)
return FALSE;
- EnterCriticalSection(&iad->cs);
+ mir_cslock lck(iad->cs);
// Get bounds
if (iad->width_based) {
@@ -500,10 +481,8 @@ BOOL ImageArray_RemoveImage(IMAGE_ARRAY_DATA *iad, int pos) // Alloc image
hNewBmp = ImageArray_CreateBitmapPoint(new_width, new_height, &(iad->lpBits));
- if (hNewBmp == NULL) {
- LeaveCriticalSection(&iad->cs);
+ if (hNewBmp == NULL)
return FALSE;
- }
// Move image...
@@ -588,9 +567,6 @@ BOOL ImageArray_RemoveImage(IMAGE_ARRAY_DATA *iad, int pos) // Free array
ImageArray_Alloc(iad, iad->nodes_size);
- // Finished it!
- LeaveCriticalSection(&iad->cs);
-
return pos;
}
@@ -601,7 +577,7 @@ BOOL ImageArray_DrawImage(IMAGE_ARRAY_DATA *iad, int pos, HDC hdcDest, int nXDes if (hdcDest == NULL || pos < 0 || pos >= iad->nodes_size)
return FALSE;
- EnterCriticalSection(&iad->cs);
+ mir_cslock lck(iad->cs);
{
int w, h, i;
@@ -624,17 +600,15 @@ BOOL ImageArray_DrawImage(IMAGE_ARRAY_DATA *iad, int pos, HDC hdcDest, int nXDes AlphaBlend(hdcDest, nXDest, nYDest, iad->nodes[pos].width, iad->nodes[pos].height, iad->hdc, w, h, iad->nodes[pos].width, iad->nodes[pos].height, bf);
}
- LeaveCriticalSection(&iad->cs);
return FALSE;
}
BOOL ImageArray_GetImageSize(IMAGE_ARRAY_DATA *iad, int pos, SIZE * lpSize)
{
- EnterCriticalSection(&iad->cs);
+ mir_cslock lck(iad->cs);
if (lpSize) {
lpSize->cx = iad->nodes[pos].width;
lpSize->cy = iad->nodes[pos].height;
}
- LeaveCriticalSection(&iad->cs);
return TRUE;
}
diff --git a/plugins/Clist_modern/src/modern_skinbutton.cpp b/plugins/Clist_modern/src/modern_skinbutton.cpp index f9ba51083c..a16a0a0edf 100644 --- a/plugins/Clist_modern/src/modern_skinbutton.cpp +++ b/plugins/Clist_modern/src/modern_skinbutton.cpp @@ -66,7 +66,7 @@ typedef struct _HandleServiceParams BOOL handled; } HandleServiceParams; -static CRITICAL_SECTION csTips; +static mir_cs csTips; static HWND hwndToolTips = NULL; int ModernSkinButtonLoadModule() @@ -81,14 +81,12 @@ int ModernSkinButtonLoadModule() wc.hbrBackground = 0; wc.style = CS_GLOBALCLASS; RegisterClassEx(&wc); - InitializeCriticalSection(&csTips); ModernSkinButtonModuleIsLoaded = TRUE; return 0; } int ModernSkinButtonUnloadModule(WPARAM, LPARAM) { - DeleteCriticalSection(&csTips); return 0; } @@ -371,9 +369,10 @@ static LRESULT CALLBACK ModernSkinButtonWndProc(HWND hwndDlg, UINT msg, WPARAM w return TRUE; case WM_DESTROY: + { if (bct == NULL) break; - EnterCriticalSection(&csTips); + mir_cslock lck(csTips); if (hwndToolTips) { TOOLINFO ti; memset(&ti, 0, sizeof(ti)); @@ -389,7 +388,6 @@ static LRESULT CALLBACK ModernSkinButtonWndProc(HWND hwndDlg, UINT msg, WPARAM w hwndToolTips = NULL; } } - LeaveCriticalSection(&csTips); mir_free(bct->ID); mir_free(bct->CommandService); mir_free(bct->StateService); @@ -399,7 +397,8 @@ static LRESULT CALLBACK ModernSkinButtonWndProc(HWND hwndDlg, UINT msg, WPARAM w mir_free(bct->ValueTypeDef); mir_free(bct); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); - break; // DONT! fall thru + } + break; // DONT! fall thru case WM_SETCURSOR: { @@ -489,7 +488,7 @@ HWND SetToolTip(HWND hwnd, TCHAR * tip) { TOOLINFO ti; if (!tip) return 0; - EnterCriticalSection(&csTips); + mir_cslock lck(csTips); if (!hwndToolTips) { // hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); @@ -517,7 +516,6 @@ HWND SetToolTip(HWND hwnd, TCHAR * tip) ti.lpszText = (TCHAR*)tip; SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM)&ti); - LeaveCriticalSection(&csTips); return hwndToolTips; } diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index d89a9842ed..e0aa2ce889 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -457,7 +457,7 @@ static int SortBufferList(const DCBUFFER *buf1, const DCBUFFER *buf2) } LIST<DCBUFFER> BufferList(2, SortBufferList); -CRITICAL_SECTION BufferListCS = { 0 }; +mir_cs BufferListCS; enum { diff --git a/plugins/Clist_modern/src/modern_skinned_profile.cpp b/plugins/Clist_modern/src/modern_skinned_profile.cpp index 6e2d4eb879..3927b1fbd6 100644 --- a/plugins/Clist_modern/src/modern_skinned_profile.cpp +++ b/plugins/Clist_modern/src/modern_skinned_profile.cpp @@ -23,15 +23,13 @@ CSkinnedProfile::~CSkinnedProfile() HRESULT CSkinnedProfile::Init()
{
- CAutoCriticalSection Lock( SkinProfile()->_Lock, true );
- SkinnedProfile.clear();
+ mir_cslock lck(_Lock);
return S_OK;
}
HRESULT CSkinnedProfile::Clear()
{
- CAutoCriticalSection Lock( SkinProfile()->_Lock, true );
- SkinnedProfile.clear();
+ mir_cslock lck(_Lock);
return S_OK;
}
@@ -54,7 +52,7 @@ BYTE CSkinnedProfile::SpiGetSkinByte( HANDLE hContact, const char * szSection, c if ( hContact )
return db_get_b( hContact, szSection, szKey, defValue ); //per-contact settings are not skinnablr at all
- CAutoCriticalSection Lock( SkinProfile()->_Lock, true );
+ mir_cslock lck(_Lock);
ValueVariant* value = SkinProfile()->_GetValue( szSection, szKey );
@@ -72,7 +70,7 @@ WORD CSkinnedProfile::SpiGetSkinWord( HANDLE hContact, const char * szSection, c if ( hContact )
return db_get_w( hContact, szSection, szKey, defValue ); //per-contact settings are not skinnablr at all
- CAutoCriticalSection Lock( SkinProfile()->_Lock, true );
+ mir_cslock lck(_Lock);
ValueVariant* value = SkinProfile()->_GetValue( szSection, szKey );
@@ -90,7 +88,7 @@ DWORD CSkinnedProfile::SpiGetSkinDword( HANDLE hContact, const char * szSection, if ( hContact )
return db_get_dw( hContact, szSection, szKey, defValue ); //per-contact settings are not skinnablr at all
- CAutoCriticalSection Lock( SkinProfile()->_Lock, true );
+ mir_cslock lck(_Lock);
ValueVariant* value = SkinProfile()->_GetValue( szSection, szKey );
@@ -108,7 +106,7 @@ BOOL CSkinnedProfile::SpiCheckSkinned( HANDLE hContact, const char * szSection, if ( hContact )
return FALSE;
- CAutoCriticalSection Lock( SkinProfile()->_Lock, true );
+ mir_cslock lck(_Lock);
return ( SkinProfile()->_GetValue( szSection, szKey ) == NULL );
}
diff --git a/plugins/Clist_modern/src/modern_tbbutton.cpp b/plugins/Clist_modern/src/modern_tbbutton.cpp index d5c6843322..95beef5399 100644 --- a/plugins/Clist_modern/src/modern_tbbutton.cpp +++ b/plugins/Clist_modern/src/modern_tbbutton.cpp @@ -30,7 +30,7 @@ struct TBBUTTONDATA : public MButtonCtrl XPTHANDLE hThemeButton, hThemeToolbar;
};
-static CRITICAL_SECTION csTips;
+static mir_cs csTips;
static HWND hwndToolTips = NULL;
static BOOL bThemed = FALSE;
|