text: Be more careful with cached layouts

If we call any functions that may call ensure_layout
themeselves, we risk having the cached layout pulled
out from underneath. Better play it safe and take a
reference.
This commit is contained in:
Matthias Clasen 2020-04-12 15:12:37 -04:00
parent 1efa781a19
commit 17a9b13af2

View File

@ -4564,7 +4564,7 @@ gtk_text_draw_cursor (GtkText *self,
context = gtk_widget_get_style_context (widget);
layout = gtk_text_ensure_layout (self, TRUE);
layout = g_object_ref (gtk_text_ensure_layout (self, TRUE));
text = pango_layout_get_text (layout);
gtk_text_get_layout_offsets (self, &x, &y);
@ -4604,6 +4604,8 @@ gtk_text_draw_cursor (GtkText *self,
gtk_style_context_restore (context);
}
g_object_unref (layout);
}
static void