Commit 132a35b8 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Don't release the dc when destroying the context.

parent 16a62fcd
...@@ -227,12 +227,13 @@ void cursor_coords( ME_TextEditor *editor, ME_Cursor *cursor, ...@@ -227,12 +227,13 @@ void cursor_coords( ME_TextEditor *editor, ME_Cursor *cursor,
ME_Run *size_run = run, *prev; ME_Run *size_run = run, *prev;
ME_Context c; ME_Context c;
int run_x; int run_x;
HDC hdc = ITextHost_TxGetDC( editor->texthost );
assert(~para->nFlags & MEPF_REWRAP); assert(~para->nFlags & MEPF_REWRAP);
row = row_from_cursor( cursor ); row = row_from_cursor( cursor );
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost)); ME_InitContext( &c, editor, hdc );
if (!cursor->nOffset && (prev = run_prev( run ))) size_run = prev; if (!cursor->nOffset && (prev = run_prev( run ))) size_run = prev;
...@@ -243,6 +244,7 @@ void cursor_coords( ME_TextEditor *editor, ME_Cursor *cursor, ...@@ -243,6 +244,7 @@ void cursor_coords( ME_TextEditor *editor, ME_Cursor *cursor,
*y = c.rcView.top + para->pt.y + row->nBaseline *y = c.rcView.top + para->pt.y + row->nBaseline
+ run->pt.y - size_run->nAscent - editor->vert_si.nPos; + run->pt.y - size_run->nAscent - editor->vert_si.nPos;
ME_DestroyContext(&c); ME_DestroyContext(&c);
ITextHost_TxReleaseDC( editor->texthost, hdc );
return; return;
} }
......
...@@ -44,5 +44,4 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC) ...@@ -44,5 +44,4 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
void ME_DestroyContext(ME_Context *c) void ME_DestroyContext(ME_Context *c)
{ {
select_style( c, NULL ); select_style( c, NULL );
if (c->hDC) ITextHost_TxReleaseDC( c->editor->texthost, c->hDC );
} }
...@@ -93,7 +93,6 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate) ...@@ -93,7 +93,6 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate)
if (oldRgn) if (oldRgn)
DeleteObject(oldRgn); DeleteObject(oldRgn);
c.hDC = NULL;
ME_DestroyContext(&c); ME_DestroyContext(&c);
} }
......
...@@ -160,8 +160,9 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) ...@@ -160,8 +160,9 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
ME_Run *run; ME_Run *run;
ME_Style *style; ME_Style *style;
int eol_len; int eol_len;
HDC hdc = ITextHost_TxGetDC( editor->texthost );
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost)); ME_InitContext( &c, editor, hdc );
hf = GetStockObject(SYSTEM_FONT); hf = GetStockObject(SYSTEM_FONT);
assert(hf); assert(hf);
...@@ -221,6 +222,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) ...@@ -221,6 +222,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
wine_rb_init( &editor->marked_paras, para_mark_compare ); wine_rb_init( &editor->marked_paras, para_mark_compare );
para_mark_add( editor, para ); para_mark_add( editor, para );
ME_DestroyContext(&c); ME_DestroyContext(&c);
ITextHost_TxReleaseDC( editor->texthost, hdc );
} }
static void para_mark_rewrap_paras( ME_TextEditor *editor, ME_Paragraph *first, const ME_Paragraph *end ) static void para_mark_rewrap_paras( ME_TextEditor *editor, ME_Paragraph *first, const ME_Paragraph *end )
......
...@@ -571,10 +571,12 @@ int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest, B ...@@ -571,10 +571,12 @@ int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest, B
{ {
ME_Context c; ME_Context c;
int ret; int ret;
HDC hdc = ITextHost_TxGetDC( editor->texthost );
ME_InitContext( &c, editor, ITextHost_TxGetDC( editor->texthost ) ); ME_InitContext( &c, editor, hdc );
ret = ME_CharFromPointContext( &c, cx, run, closest, visual_order ); ret = ME_CharFromPointContext( &c, cx, run, closest, visual_order );
ME_DestroyContext(&c); ME_DestroyContext(&c);
ITextHost_TxReleaseDC( editor->texthost, hdc );
return ret; return ret;
} }
...@@ -648,10 +650,12 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visu ...@@ -648,10 +650,12 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visu
{ {
ME_Context c; ME_Context c;
int ret; int ret;
HDC hdc = ITextHost_TxGetDC( editor->texthost );
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost)); ME_InitContext( &c, editor, hdc );
ret = ME_PointFromCharContext( &c, pRun, nOffset, visual_order ); ret = ME_PointFromCharContext( &c, pRun, nOffset, visual_order );
ME_DestroyContext(&c); ME_DestroyContext(&c);
ITextHost_TxReleaseDC( editor->texthost, hdc );
return ret; return ret;
} }
......
...@@ -1027,10 +1027,12 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) ...@@ -1027,10 +1027,12 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
ME_Context c; ME_Context c;
int totalWidth = editor->nTotalWidth, prev_width; int totalWidth = editor->nTotalWidth, prev_width;
struct repaint_range repaint = { NULL, NULL }; struct repaint_range repaint = { NULL, NULL };
HDC hdc;
if (!editor->marked_paras.root) return FALSE; if (!editor->marked_paras.root) return FALSE;
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost)); hdc = ITextHost_TxGetDC( editor->texthost );
ME_InitContext( &c, editor, hdc );
entry = wine_rb_head( editor->marked_paras.root ); entry = wine_rb_head( editor->marked_paras.root );
while (entry) while (entry)
...@@ -1085,6 +1087,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) ...@@ -1085,6 +1087,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
editor->nTotalWidth = totalWidth; editor->nTotalWidth = totalWidth;
ME_DestroyContext(&c); ME_DestroyContext(&c);
ITextHost_TxReleaseDC( editor->texthost, hdc );
if (repaint.start || editor->nTotalLength < editor->nLastTotalLength) if (repaint.start || editor->nTotalLength < editor->nLastTotalLength)
para_range_invalidate( editor, repaint.start, repaint.end); para_range_invalidate( editor, repaint.start, repaint.end);
......
...@@ -939,11 +939,13 @@ static BOOL stream_out_graphics( ME_TextEditor *editor, ME_OutStream *stream, ...@@ -939,11 +939,13 @@ static BOOL stream_out_graphics( ME_TextEditor *editor, ME_OutStream *stream,
UINT size; UINT size;
SIZE goal, pic; SIZE goal, pic;
ME_Context c; ME_Context c;
HDC hdc;
hr = IOleObject_QueryInterface( run->reobj->obj.poleobj, &IID_IDataObject, (void **)&data ); hr = IOleObject_QueryInterface( run->reobj->obj.poleobj, &IID_IDataObject, (void **)&data );
if (FAILED(hr)) return FALSE; if (FAILED(hr)) return FALSE;
ME_InitContext( &c, editor, ITextHost_TxGetDC( editor->texthost ) ); hdc = ITextHost_TxGetDC( editor->texthost );
ME_InitContext( &c, editor, hdc );
hr = IDataObject_QueryGetData( data, &fmt ); hr = IDataObject_QueryGetData( data, &fmt );
if (hr != S_OK) goto done; if (hr != S_OK) goto done;
...@@ -985,6 +987,7 @@ static BOOL stream_out_graphics( ME_TextEditor *editor, ME_OutStream *stream, ...@@ -985,6 +987,7 @@ static BOOL stream_out_graphics( ME_TextEditor *editor, ME_OutStream *stream,
done: done:
ME_DestroyContext( &c ); ME_DestroyContext( &c );
ITextHost_TxReleaseDC( editor->texthost, hdc );
HeapFree( GetProcessHeap(), 0, emf_bits ); HeapFree( GetProcessHeap(), 0, emf_bits );
ReleaseStgMedium( &med ); ReleaseStgMedium( &med );
IDataObject_Release( data ); IDataObject_Release( data );
......
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