Module: wine Branch: master Commit: b70eb32c5f3e506181d9e1e9fbef62e9baf3674d URL: https://gitlab.winehq.org/wine/wine/-/commit/b70eb32c5f3e506181d9e1e9fbef62e...
Author: Jinoh Kang jinoh.kang.kr@gmail.com Date: Sat Jul 1 13:22:46 2023 +0900
riched20: Wrap marked paragraphs at Text Services initialization.
Today, CreateTextServices() returns an Rich Edit object without row start and end marks, which are expected to exist by many Rich Edit operations as well as EM_* message handlers.
This leads to a crash when certain messages (e.g., EM_SCROLLCARET) are sent to the Rich Edit object via ITextServices::TxSendMessage(), unless ME_WrapMarkedParagraphs() has been called beforehand.
Fix this by calling wrap_marked_paras_dc() early in the initialization process.
This is not a problem for windowed Rich Edit controls, which already calls ME_WrapMarkedParagraphs() before the user or application starts interacting with it.
---
dlls/riched20/para.c | 1 + dlls/riched20/tests/txtsrv.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index 357d6797c8c..6085816f315 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -222,6 +222,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) wine_rb_init( &editor->marked_paras, para_mark_compare ); para_mark_add( editor, para ); ME_DestroyContext(&c); + wrap_marked_paras_dc( editor, hdc, FALSE ); ITextHost_TxReleaseDC( editor->texthost, hdc ); }
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 830a95e37c5..63d622a6755 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -1292,6 +1292,23 @@ static void test_set_selection_message( void ) ITextHost_Release( host ); }
+static void test_scrollcaret( void ) +{ + ITextServices *txtserv; + ITextHost *host; + LRESULT result; + HRESULT hr; + + if (!init_texthost(&txtserv, &host)) + return; + + hr = ITextServices_TxSendMessage(txtserv, EM_SCROLLCARET, 0, 0, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + ITextServices_Release( txtserv ); + ITextHost_Release( host ); +} + START_TEST( txtsrv ) { ITextServices *txtserv; @@ -1326,6 +1343,7 @@ START_TEST( txtsrv ) test_TxGetScroll(); test_notifications(); test_set_selection_message(); + test_scrollcaret(); } if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE); }