According to microsoft documentation, ScrollWindowEx, SetScrollPos and SetScrollRange may only be called while the control is in-place active.
This fixes a segmentation fault in Anytone CPS.
-- v3: riched20/tests: Test that ScrollWindowEx is only called when control is in-place active.
From: Charlotte Pabst cpabst@codeweavers.com
According to microsoft documentation, ScrollWindowEx, SetScrollPos and SetScrollRange may only be called while the control is in-place active.
This fixes a segmentation fault in an application.
Signed-off-by: Charlotte Pabst cpabst@codeweavers.com --- dlls/riched20/paint.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 8bc1b8bcd2f..54b7ffd82bc 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -1212,6 +1212,8 @@ void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor ) ME_Paragraph *para = cursor->para; int x, y, yheight;
+ if (!editor->in_place_active) + return;
if (editor->scrollbars & ES_AUTOHSCROLL) {
From: Charlotte Pabst cpabst@codeweavers.com
Signed-off-by: Charlotte Pabst cpabst@codeweavers.com --- dlls/riched20/tests/txtsrv.c | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index adb36642f4f..da986291474 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -103,6 +103,7 @@ static ITextServicesVtbl itextServicesStdcallVtbl; /* ITextHost implementation for conformance testing. */
DEFINE_EXPECT(ITextHostImpl_TxViewChange); +DEFINE_EXPECT(ITextHostImpl_TxScrollWindowEx);
typedef struct ITextHostTestImpl { @@ -268,6 +269,7 @@ static void __thiscall ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxScrollWindowEx(%p, %d, %d, %p, %p, %p, %p, %d)\n", This, dx, dy, lprcScroll, lprcClip, hRgnUpdate, lprcUpdate, fuScroll); + INCREASE_CALL_COUNTER(ITextHostImpl_TxScrollWindowEx); }
static void __thiscall ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture) @@ -1396,6 +1398,54 @@ static void test_scrollcaret( void ) ITextHost_Release( host ); }
+static void test_replace_selection( void ) +{ + ITextServices *txtserv; + ITextHost *host; + LRESULT result; + HRESULT hr; + + ITextHostTestImpl *host_impl; + if (!init_texthost(&txtserv, &host)) + return; + + host_impl = impl_from_ITextHost( host ); + host_impl->window = CreateWindowExA( 0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 100, 100, 0, 0, 0, NULL ); + host_impl->client_rect = (RECT) { 0, 0, 150, 150 }; + host_impl->scrollbars = WS_VSCROLL | ES_AUTOVSCROLL; + host_impl->props = TXTBIT_MULTILINE | TXTBIT_RICHTEXT | TXTBIT_WORDWRAP; + ITextServices_OnTxPropertyBitsChange( txtserv, TXTBIT_SCROLLBARCHANGE | TXTBIT_MULTILINE | TXTBIT_RICHTEXT | TXTBIT_WORDWRAP, host_impl->props ); + + CLEAR_COUNTER(ITextHostImpl_TxScrollWindowEx); + + hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, GetDC(host_impl->window), NULL, (RECTL *)&host_impl->client_rect, NULL, NULL, NULL, 0, TXTVIEW_INACTIVE ); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ITextServices_TxSendMessage(txtserv, EM_SETSEL, 0, -1, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ITextServices_TxSendMessage(txtserv, EM_REPLACESEL, TRUE, (LPARAM) lorem, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + CHECK_NOT_CALLED(ITextHostImpl_TxScrollWindowEx); + CLEAR_COUNTER(ITextHostImpl_TxScrollWindowEx); + + hr = ITextServices_OnTxInPlaceActivate( txtserv, &host_impl->client_rect ); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ITextServices_TxSendMessage(txtserv, EM_SETSEL, 0, -1, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ITextServices_TxSendMessage(txtserv, EM_REPLACESEL, TRUE, (LPARAM) lorem, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + CHECK_CALLED(ITextHostImpl_TxScrollWindowEx); + + DestroyWindow( host_impl->window ); + ITextServices_Release( txtserv ); + ITextHost_Release( host ); +} + START_TEST( txtsrv ) { ITextServices *txtserv; @@ -1431,6 +1481,7 @@ START_TEST( txtsrv ) test_notifications(); test_set_selection_message(); test_scrollcaret(); + test_replace_selection(); } if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE); }
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=148829
Your paranoid android.
=== debian11 (32 bit ja:JP report) ===
riched20: txtsrv.c:1442: Test failed: expected ITextHostImpl_TxScrollWindowEx
=== debian11 (32 bit zh:CN report) ===
riched20: txtsrv.c:1442: Test failed: expected ITextHostImpl_TxScrollWindowEx