summaryrefslogtreecommitdiff
path: root/plugins/SmileyAdd/src/richcall.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SmileyAdd/src/richcall.cpp')
-rw-r--r--plugins/SmileyAdd/src/richcall.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/plugins/SmileyAdd/src/richcall.cpp b/plugins/SmileyAdd/src/richcall.cpp
index 0c3af9c77a..3a7f0ae58a 100644
--- a/plugins/SmileyAdd/src/richcall.cpp
+++ b/plugins/SmileyAdd/src/richcall.cpp
@@ -35,6 +35,7 @@ struct RichEditOwnerData
HWND hwndLog;
};
+static mir_cs csLists;
static LIST<RichEditData> g_RichEditList(10, HandleKeySortT);
static LIST<RichEditOwnerData> g_RichEditOwnerList(5, HandleKeySortT);
@@ -203,6 +204,10 @@ static LRESULT CALLBACK RichEditSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LP
ReplaceContactSmileysWithText(rdt, sel, true);
}
break;
+
+ case WM_DESTROY:
+ CloseRichCallback(hwnd);
+ break;
}
LRESULT result = mir_callNextSubclass(hwnd, RichEditSubclass, uMsg, wParam, lParam);
@@ -304,8 +309,10 @@ bool SetRichCallback(HWND hwnd, MCONTACT hContact, bool subany, bool subnew)
rdt->hContact = hContact;
rdt->inputarea = (GetWindowLongPtr(hwnd, GWL_STYLE) & ES_READONLY) == 0;
rdt->tipActive = -1;
- g_RichEditList.insert(rdt);
-
+ {
+ mir_cslock lck(csLists);
+ g_RichEditList.insert(rdt);
+ }
if (subnew)
mir_subclassWindow(hwnd, RichEditSubclass);
}
@@ -321,15 +328,20 @@ bool SetRichCallback(HWND hwnd, MCONTACT hContact, bool subany, bool subnew)
void CloseRichCallback(HWND hwnd)
{
- int ind = g_RichEditList.getIndex((RichEditData*)&hwnd);
- if (ind == -1)
- return;
+ RichEditData *rdt;
+ {
+ mir_cslock lck(csLists);
+ int ind = g_RichEditList.getIndex((RichEditData *)&hwnd);
+ if (ind == -1)
+ return;
+
+ rdt = g_RichEditList[ind];
+ g_RichEditList.remove(ind);
+ }
- RichEditData *rdt = g_RichEditList[ind];
if (rdt->hToolTip)
DestroyWindow(rdt->hToolTip);
delete rdt;
- g_RichEditList.remove(ind);
mir_unsubclassWindow(hwnd, RichEditSubclass);
}