summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Piastucki <leech.miranda@gmail.com>2015-05-18 11:42:31 +0000
committerPiotr Piastucki <leech.miranda@gmail.com>2015-05-18 11:42:31 +0000
commit65293fe3106fa78417263122ad1b35ee19d4540d (patch)
tree21820c541ebcb5a78975cead5a4bc70992a9bd39
parent357a83faeeccfbef13a11580cb75f76d96b584cd (diff)
RichEdit Control doesn't support WM_GETFONT: https://msdn.microsoft.com/en-us/library/windows/desktop/bb787873%28v=vs.85%29.aspx
This lead to a font handle leak in msgdialog. git-svn-id: http://svn.miranda-ng.org/main/trunk@13677 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp16
-rw-r--r--src/core/stdmsg/src/msgs.h1
2 files changed, 8 insertions, 9 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 1699b3a74c..9e72a86f62 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -1042,15 +1042,12 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
InvalidateRect(GetDlgItem(hwndDlg, IDC_MESSAGE), NULL, FALSE);
{
- HFONT hFont;
LOGFONT lf;
CHARFORMAT cf = { 0 };
- hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_GETFONT, 0, 0);
- if (hFont != NULL && hFont != (HFONT)SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0))
- DeleteObject(hFont);
+ if (dat->hFont) DeleteObject(dat->hFont);
LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &cf.crTextColor);
- hFont = CreateFontIndirect(&lf);
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
+ dat->hFont = CreateFontIndirect(&lf);
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_SETFONT, (WPARAM)dat->hFont, MAKELPARAM(TRUE, 0));
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR;
@@ -1713,9 +1710,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
WindowList_Remove(g_dat.hMessageWindowList, hwndDlg);
db_set_dw(bSavePerContact ? dat->hContact : NULL, SRMMMOD, "splitterPos", dat->splitterPos);
- HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_GETFONT, 0, 0);
- if (hFont != NULL && hFont != (HFONT)SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0))
- DeleteObject(hFont);
+ if (dat->hFont) {
+ DeleteObject(dat->hFont);
+ dat->hFont = NULL;
+ }
MCONTACT hContact = (bSavePerContact) ? dat->hContact : NULL;
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index e59175c0d2..940e242e27 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -42,6 +42,7 @@ struct SrmmWindowData : public MZeroedObject
MCONTACT hContact;
MEVENT hDbEventFirst, hDbEventLast;
HBRUSH hBkgBrush;
+ HFONT hFont;
int splitterPos, originalSplitterPos;
SIZE minEditBoxSize;
RECT minEditInit;