Commit: patch 9.2.0956: GTK4: crash when the window is resized while redrawing
Christian Brabandt <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <[email protected]> |
patch 9.2.0956: GTK4: crash when the window is resized while redrawing Commit: https://github.com/vim/vim/commit/fc6288f517c02ac66f6e83a57dc0e515a540b7a1 Author: Hirohito Higashi <[email protected]> Date: Wed Aug 12 21:45:46 2026 +0000 patch 9.2.0956: GTK4: crash when the window is resized while redrawing Problem: In GTK4, Vim may crash when the window is resized while the cursor is displayed. Solution: Remember the number of cells the cursor covers when the cursor is set, instead of deriving it from the drawing position when the snapshot is taken (Hirohito Higashi). fixes: #21037 closes: #21038 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Hirohito Higashi <[email protected]> Signed-off-by: Foxe Chen <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/src/gui_gtk4_da.c b/src/gui_gtk4_da.c index 330706e86..d7e460254 100644 --- a/src/gui_gtk4_da.c +++ b/src/gui_gtk4_da.c @@ -133,6 +133,7 @@ typedef struct gboolean draw; // If cursor should be drawn int width; int height; + int n_cells; // Cells covered, 2 for a double width character GdkRGBA bg_color; GdkRGBA fg_color; } DrawCursor; @@ -1598,6 +1599,9 @@ vim_draw_area_set_cursor(VimDrawArea *self, int w, int h) self->cursor.draw = TRUE; self->cursor.width = w; self->cursor.height = h; + // Remember this now: the snapshot runs later, when the drawing position + // has moved on. + self->cursor.n_cells = 1 + mb_lefthalve(gui.cursor_row, gui.cursor_col); self->cursor.bg_color = *gui.bgcolor; self->cursor.fg_color = *gui.fgcolor; } @@ -1873,8 +1877,7 @@ vim_draw_area_snapshot_cursor( if (cursor->width <= 0 && cursor->height <= 0) { - // Double width if double width character - w += gui.char_width * (1 + mb_lefthalve(gui.row, gui.col)); + w += gui.char_width * cursor->n_cells; h = gui.char_height; } diff --git a/src/version.c b/src/version.c index 4a6e48ce4..2be3c231f 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 956, /**/ 955, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wuZir-0022uq-L4%40256bit.org.