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
From: Jinoh Kang jinoh.kang.kr@gmail.com
This lets ME_MakeEditor() reuse the device context throughout the editor initialization process. --- dlls/riched20/editor.c | 6 +++++- dlls/riched20/editor.h | 2 +- dlls/riched20/para.c | 4 +--- 3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 201c4435453..d1819482b28 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2931,6 +2931,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) int i; LONG selbarwidth; HRESULT hr; + HDC hdc;
ed->sizeWindow.cx = ed->sizeWindow.cy = 0; if (ITextHost_QueryInterface( texthost, &IID_ITextHost2, (void **)&ed->texthost ) == S_OK) @@ -2957,7 +2958,10 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ed->nZoomNumerator = ed->nZoomDenominator = 0; ed->nAvailWidth = 0; /* wrap to client area */ list_init( &ed->style_list ); - ME_MakeFirstParagraph(ed); + + 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) diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index da7d3bd35fd..1ad8f4adef4 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -209,7 +209,7 @@ void editor_get_selection_para_fmt( ME_TextEditor *editor, PARAFORMAT2 *fmt ); void editor_mark_rewrap_all( ME_TextEditor *editor ); void editor_set_default_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *pFmt); BOOL editor_set_selection_para_fmt( ME_TextEditor *editor, const PARAFORMAT2 *fmt ); -void ME_MakeFirstParagraph(ME_TextEditor *editor); +void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc); void ME_DumpParaStyle(ME_Paragraph *s); void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]); int get_total_width(ME_TextEditor *editor); diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index 6085816f315..50a1073397a 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -148,7 +148,7 @@ ME_Row *para_end_row( ME_Paragraph *para ) return &item->member.row; }
-void ME_MakeFirstParagraph(ME_TextEditor *editor) +void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc) { ME_Context c; CHARFORMAT2W cf; @@ -160,7 +160,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) ME_Run *run; ME_Style *style; int eol_len; - HDC hdc = ITextHost_TxGetDC( editor->texthost );
ME_InitContext( &c, editor, hdc );
@@ -223,7 +222,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) para_mark_add( editor, para ); ME_DestroyContext(&c); wrap_marked_paras_dc( editor, hdc, FALSE ); - ITextHost_TxReleaseDC( editor->texthost, hdc ); }
static void para_mark_rewrap_paras( ME_TextEditor *editor, ME_Paragraph *first, const ME_Paragraph *end )
From: Jinoh Kang jinoh.kang.kr@gmail.com
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 )
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=134826
Your paranoid android.
=== debian11 (32 bit zh:CN report) ===
riched20: editor.c:5746: Test failed: Failed to paste clipboard content
On Thu Jul 13 12:35:00 2023 +0000, **** wrote:
Marvin replied on the mailing list:
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=134826 Your paranoid android. === debian11 (32 bit zh:CN report) === riched20: editor.c:5746: Test failed: Failed to paste clipboard content
Likely a manifestation of https://bugs.winehq.org/show_bug.cgi?id=53507
This merge request was approved by Huw Davies.