diff options
author | George Hazan <ghazan@miranda.im> | 2020-04-20 14:59:31 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-04-20 14:59:31 +0300 |
commit | d055638795e2d803ed016015f59e1824f840dd84 (patch) | |
tree | 78ffa0186fc201082314ceedda353ff07e035fe1 /plugins/SmileyAdd | |
parent | 4ea593493aeff473146e0baf0d41558ef5dbec05 (diff) |
SmileyAdd: fix for a huge memory leak when destroying temporary windows with smileys
Diffstat (limited to 'plugins/SmileyAdd')
-rw-r--r-- | plugins/SmileyAdd/src/richcall.cpp | 26 |
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);
}
|