Fix a critical in GtkFontChooserWidget

When the level doesn't include the style, we need
to work a bit harder to really get a face object
here.

Fixes: #5173
This commit is contained in:
Matthias Clasen 2022-09-13 08:54:09 -04:00
parent 9baae419f6
commit ea9aa8ed82

View File

@ -963,11 +963,12 @@ gtk_font_chooser_widget_load_fonts (GtkFontChooserWidget *fontchooser,
if ((priv->level & GTK_FONT_CHOOSER_LEVEL_STYLE) == 0) if ((priv->level & GTK_FONT_CHOOSER_LEVEL_STYLE) == 0)
{ {
GtkDelayedFontDescription *desc; GtkDelayedFontDescription *desc;
PangoFontFace *face; PangoFontFace *face = NULL;
#if PANGO_VERSION_CHECK(1,46,0) #if PANGO_VERSION_CHECK(1,46,0)
face = pango_font_family_get_face (families[i], NULL); face = pango_font_family_get_face (families[i], NULL);
#else #endif
if (!face)
{ {
PangoFontFace **faces; PangoFontFace **faces;
int j, n_faces; int j, n_faces;
@ -981,9 +982,10 @@ gtk_font_chooser_widget_load_fonts (GtkFontChooserWidget *fontchooser,
break; break;
} }
} }
g_free (faces); g_free (faces);
} }
#endif
desc = gtk_delayed_font_description_new (face); desc = gtk_delayed_font_description_new (face);
gtk_list_store_insert_with_values (list_store, &iter, -1, gtk_list_store_insert_with_values (list_store, &iter, -1,