Commit 5d36c47e authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

richedit: Fixed object leaks generated by context creation & destruction.

parent 33d7cea1
......@@ -215,9 +215,8 @@ ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
*height = pSizeRun->member.run.nAscent + pSizeRun->member.run.nDescent;
*x = run->member.run.pt.x + sz.cx;
*y = para->member.para.nYPos + row->member.row.nBaseline + pSizeRun->member.run.pt.y - pSizeRun->member.run.nAscent - ME_GetYScrollPos(editor);
ME_DestroyContext(&c);
ReleaseDC(editor->hWnd, hDC);
ME_DestroyContext(&c, editor->hWnd);
return;
}
}
......
......@@ -33,7 +33,8 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
c->dpi.cy = GetDeviceCaps(hDC, LOGPIXELSY);
}
void ME_DestroyContext(ME_Context *c)
void ME_DestroyContext(ME_Context *c, HWND hWnd)
{
if (hWnd) ReleaseDC(hWnd, c->hDC);
DeleteObject(c->hbrMargin);
}
......@@ -190,7 +190,7 @@ void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor);
BOOL ME_ArrowKey(ME_TextEditor *ed, int nVKey, BOOL extend, BOOL ctrl);
void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC);
void ME_DestroyContext(ME_Context *c);
void ME_DestroyContext(ME_Context *c, HWND release);
ME_Style *GetInsertStyle(ME_TextEditor *editor, int nCursor);
void ME_MustBeWrapped(ME_Context *c, ME_DisplayItem *para);
void ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
......
......@@ -91,7 +91,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *
if (editor->nTotalLength != editor->nLastTotalLength)
ME_SendRequestResize(editor, FALSE);
editor->nLastTotalLength = editor->nTotalLength;
ME_DestroyContext(&c);
ME_DestroyContext(&c, NULL);
}
void ME_Repaint(ME_TextEditor *editor)
......
......@@ -28,7 +28,6 @@ static const WCHAR wszParagraphSign[] = {0xB6, 0};
void ME_MakeFirstParagraph(ME_TextEditor *editor)
{
ME_Context c;
HDC hDC;
PARAFORMAT2 fmt;
CHARFORMAT2W cf;
LOGFONTW lf;
......@@ -38,9 +37,8 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
ME_DisplayItem *run;
ME_Style *style;
hDC = GetDC(editor->hWnd);
ME_InitContext(&c, editor, GetDC(editor->hWnd));
ME_InitContext(&c, editor, hDC);
hf = (HFONT)GetStockObject(SYSTEM_FONT);
assert(hf);
GetObjectW(hf, sizeof(LOGFONTW), &lf);
......@@ -85,8 +83,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
text->pLast->member.para.nCharOfs = 1;
ME_DestroyContext(&c);
ReleaseDC(editor->hWnd, hDC);
ME_DestroyContext(&c, editor->hWnd);
}
void ME_MarkAllForWrapping(ME_TextEditor *editor)
......
......@@ -551,7 +551,7 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
{
SIZE sz;
ME_GetOLEObjectSize(&c, run, &sz);
ReleaseDC(editor->hWnd, c.hDC);
ME_DestroyContext(&c, editor->hWnd);
if (cx < sz.cx/2)
return 0;
return 1;
......@@ -580,7 +580,7 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
ME_DestroyString(strRunText);
ME_UnselectStyleFont(&c, run->style, hOldFont);
ReleaseDC(editor->hWnd, c.hDC);
ME_DestroyContext(&c, editor->hWnd);
return fit;
}
......
......@@ -467,14 +467,12 @@ static void ME_PrepareParagraphForWrapping(ME_Context *c, ME_DisplayItem *tp) {
}
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
HWND hWnd = editor->hWnd;
HDC hDC = GetDC(hWnd);
ME_DisplayItem *item;
ME_Context c;
BOOL bModified = FALSE;
int yStart = -1, yEnd = -1;
ME_InitContext(&c, editor, hDC);
ME_InitContext(&c, editor, GetDC(editor->hWnd));
c.pt.x = 0;
c.pt.y = 0;
editor->nHeight = 0;
......@@ -510,9 +508,8 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
editor->nTotalLength = c.pt.y;
ME_DestroyContext(&c);
ReleaseDC(hWnd, hDC);
ME_DestroyContext(&c, editor->hWnd);
if (bModified || editor->nTotalLength < editor->nLastTotalLength)
ME_InvalidateMarkedParagraphs(editor);
return bModified;
......@@ -520,9 +517,8 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor) {
ME_Context c;
HDC hDC = GetDC(editor->hWnd);
ME_InitContext(&c, editor, hDC);
ME_InitContext(&c, editor, GetDC(editor->hWnd));
if (editor->bRedraw)
{
RECT rc = c.rcView;
......@@ -544,8 +540,7 @@ void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor) {
InvalidateRect(editor->hWnd, &rc, TRUE);
}
}
ME_DestroyContext(&c);
ReleaseDC(editor->hWnd, hDC);
ME_DestroyContext(&c, editor->hWnd);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment