Module: wine Branch: master Commit: 548d7179e3b2b9961321a4df50644c9b3874a295 URL: https://gitlab.winehq.org/wine/wine/-/commit/548d7179e3b2b9961321a4df50644c9...
Author: Jinoh Kang jinoh.kang.kr@gmail.com Date: Thu Jul 13 20:50:27 2023 +0900
riched20: Don't call wrap_marked_paras_dc() before the editor is fully initialized.
Today, CreateTextServices() sometimes triggers an assertion failure in select_style().
When ME_MakeEditor() calls ME_MakeFirstParagraph(), the editor (ME_TextEditor) is not in a fully initialized state. For example, the font cache (pFontCache) is not fully initialized, which sometimes makes select_style() believe that the cache slots are fully occupied.
Fix this by delaying the call to wrap_marked_paras_dc() until the editor is fully initialized.
Also, delay the call to ITextHost::TxReleaseDC() until after wrap_marked_paras_dc(), since we need the device context a bit longer.
Fixes: b70eb32c5f3e506181d9e1e9fbef62e9baf3674d
---
dlls/riched20/editor.c | 4 +++- dlls/riched20/para.c | 1 - 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index d1819482b28..2b0d6533659 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2961,7 +2961,6 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
hdc = ITextHost_TxGetDC( ed->texthost ); ME_MakeFirstParagraph( ed, hdc ); - ITextHost_TxReleaseDC( ed->texthost, hdc ); /* The four cursors are for: * 0 - The position where the caret is shown * 1 - The anchored end of the selection (for normal selection) @@ -3061,6 +3060,9 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) list_init( &ed->reobj_list ); OleInitialize(NULL);
+ wrap_marked_paras_dc( ed, hdc, FALSE ); + ITextHost_TxReleaseDC( ed->texthost, hdc ); + return ed; }
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index 50a1073397a..a380f45e556 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -221,7 +221,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc) wine_rb_init( &editor->marked_paras, para_mark_compare ); para_mark_add( editor, para ); ME_DestroyContext(&c); - wrap_marked_paras_dc( editor, hdc, FALSE ); }
static void para_mark_rewrap_paras( ME_TextEditor *editor, ME_Paragraph *first, const ME_Paragraph *end )