summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src/richutil.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-13 10:50:59 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-13 10:50:59 +0000
commit5df94ff719eccd04c7450df35fb5e3f2b36e2ee7 (patch)
tree440d736b199ff849ca0619adf355ffc73750ca7f /plugins/Scriver/src/richutil.cpp
parent70496fb739225b559a251f4518c946110aef718c (diff)
wrapping the most evident critical sections into a class
git-svn-id: http://svn.miranda-ng.org/main/trunk@9785 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Scriver/src/richutil.cpp')
-rw-r--r--plugins/Scriver/src/richutil.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/plugins/Scriver/src/richutil.cpp b/plugins/Scriver/src/richutil.cpp
index 9de434bc9e..7a338492ee 100644
--- a/plugins/Scriver/src/richutil.cpp
+++ b/plugins/Scriver/src/richutil.cpp
@@ -45,7 +45,7 @@ static int RichUtil_CmpVal(void *p1, void *p2)
return (int)((INT_PTR)tp1->hwnd - (INT_PTR)tp2->hwnd);
}
-static CRITICAL_SECTION csRich;
+static mir_cs csRich;
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static void RichUtil_ClearUglyBorder(TRichUtil *ru);
@@ -54,14 +54,11 @@ void RichUtil_Load(void)
{
sListInt.increment = 10;
sListInt.sortFunc = RichUtil_CmpVal;
-
- InitializeCriticalSection(&csRich);
}
void RichUtil_Unload(void)
{
List_Destroy(&sListInt);
- DeleteCriticalSection(&csRich);
}
int RichUtil_SubClass(HWND hwndEdit)
@@ -73,12 +70,11 @@ int RichUtil_SubClass(HWND hwndEdit)
ru->hwnd = hwndEdit;
ru->hasUglyBorder = 0;
-
- EnterCriticalSection(&csRich);
- if (!List_GetIndex(&sListInt, ru, &idx))
- List_Insert(&sListInt, ru, idx);
- LeaveCriticalSection(&csRich);
-
+ {
+ mir_cslock lck(csRich);
+ if (!List_GetIndex(&sListInt, ru, &idx))
+ List_Insert(&sListInt, ru, idx);
+ }
mir_subclassWindow(ru->hwnd, RichUtil_Proc);
RichUtil_ClearUglyBorder(ru);
return 1;
@@ -93,11 +89,11 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
LRESULT ret;
tru.hwnd = hwnd;
-
- EnterCriticalSection(&csRich);
- if (List_GetIndex(&sListInt, &tru, &idx))
- ru = (TRichUtil *)sListInt.items[idx];
- LeaveCriticalSection(&csRich);
+ {
+ mir_cslock lck(csRich);
+ if (List_GetIndex(&sListInt, &tru, &idx))
+ ru = (TRichUtil *)sListInt.items[idx];
+ }
switch (msg) {
case WM_THEMECHANGED:
@@ -182,11 +178,10 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case WM_NCDESTROY:
ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
-
- EnterCriticalSection(&csRich);
- List_Remove(&sListInt, idx);
- LeaveCriticalSection(&csRich);
-
+ {
+ mir_cslock lck(csRich);
+ List_Remove(&sListInt, idx);
+ }
mir_free(ru);
return ret;
}