Emoji chooser spews criticals when the pango layout changes while the emoji chooser is open
Right now, this is easy to reproduce:
- show an emoji chooser in the combobox in the upper left of page 1 in the widget-factory
- Press Arrow Down
- Select an emoji to insert with your mouse
Point 2) does not actually move the keyboard focus to the emoji flowbox, which is a bug in itself, but it makes it very easy to reproduce this problem.
The terminal output is:
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.713: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.713: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.713: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.713: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.713: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.713: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.720: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.720: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.720: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
(gtk4-widget-factory:1158982): Pango-CRITICAL **: 15:36:08.720: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
The backtrace looks something like:
#0 _g_log_abort (breakpoint=1) at ../subprojects/glib/glib/gmessages.c:557
#1 0x00007ffff7616fe0 in g_logv (log_domain=0x7ffff6f3f5ca "Pango", log_level=G_LOG_LEVEL_CRITICAL,
format=0x7ffff76776e7 "%s: assertion '%s' failed", args=0x7fffffffaf78)
at ../subprojects/glib/glib/gmessages.c:1373
#2 0x00007ffff76170d1 in g_log (log_domain=0x7ffff6f3f5ca "Pango", log_level=G_LOG_LEVEL_CRITICAL,
format=0x7ffff76776e7 "%s: assertion '%s' failed") at ../subprojects/glib/glib/gmessages.c:1415
#3 0x00007ffff7618f8b in g_return_if_fail_warning (log_domain=0x7ffff6f3f5ca "Pango",
pretty_function=0x7ffff6f40750 <__func__.18943> "pango_layout_get_cursor_pos",
expression=0x7ffff6f3f8d8 "index >= 0 && index <= layout->length") at ../subprojects/glib/glib/gmessages.c:2771
#4 0x00007ffff6f1d661 in pango_layout_get_cursor_pos (layout=0x1b81570, index=13, strong_pos=0x7fffffffb120,
weak_pos=0x7fffffffb110) at ../subprojects/pango/pango/pango-layout.c:2412
#5 0x00007ffff799465c in gtk_text_get_cursor_locations (self=0x7062f0, strong_x=0x7fffffffb188,
weak_x=0x7fffffffb184) at ../gtk/gtktext.c:4757
#6 0x00007ffff7994934 in gtk_text_adjust_scroll (self=0x7062f0) at ../gtk/gtktext.c:4867
#7 0x00007ffff7993558 in gtk_text_recompute (self=0x7062f0) at ../gtk/gtktext.c:4257
#8 0x00007ffff79934cd in gtk_text_set_positions (self=0x7062f0, current_pos=13, selection_bound=0)
at ../gtk/gtktext.c:4232
#9 0x00007ffff79990a2 in emoji_picked (chooser=0x6c1d10, text=0x1baa7e0 "😎️", self=0x7062f0)
at ../gtk/gtktext.c:6788
In my example:
(gdb) p index
$1 = 13
(gdb) p text
$2 = 0x1bbe7e0 "Donald Duck"
(gdb) p priv->current_pos
$3 = 13
(gdb) p priv->preedit_cursor
$4 = 0