This is to prevent NULL pointers when creating a standalone text service that doesn't have any text set and then using functions like EM_SETSEL. This NULL pointers doesn't happen when creating a richedit windows, because it sets an empty text when the richedit window procedure handles the WM_CREATE event.
-- v3: riched20: Check if row is null in editor_ensure_visible. riched20: Return NULL if no row is found in row_from_cursor.
From: Santino Mazza smazza@codeweavers.com
--- dlls/riched20/row.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/riched20/row.c b/dlls/riched20/row.c index 715d2adbf62..922e92f5836 100644 --- a/dlls/riched20/row.c +++ b/dlls/riched20/row.c @@ -76,6 +76,7 @@ ME_Row *row_from_cursor( ME_Cursor *cursor ) ME_DisplayItem *item;
item = ME_FindItemBack( run_get_di( cursor->run ), diStartRow ); + if (!item) return NULL; return &item->member.row; }
From: Santino Mazza smazza@codeweavers.com
--- dlls/riched20/paint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 8bc1b8bcd2f..8a4a16a8c2b 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -1212,7 +1212,7 @@ void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor ) ME_Paragraph *para = cursor->para; int x, y, yheight;
- + if (!row) return; if (editor->scrollbars & ES_AUTOHSCROLL) { x = run->pt.x + ME_PointFromChar( editor, run, cursor->nOffset, TRUE );
This looks like it's hiding the problem. I think what you want to do is to call `ME_WrapMarkedParagraphs()` at the start of `set_selection()`.
Apparently by just calling `ME_WrapMarkedParagraphs()` I get other crashes when running a program that makes use of Microsoft Forms. I solved this by calling `ME_UpdateRepaint()`, so basically the fix would be to call `ME_UpdateRepaint()` instead of `editor_ensure_visible`.