ui: Fix crash getting default font

A correctly constructed GtkStyleContext must have its screen
and widget paths set. Getting the frame font caused crashes
on some systems because those were not correctly initialised.

https://bugzilla.gnome.org/show_bug.cgi?id=696814
This commit is contained in:
Bastien Nocera 2013-03-29 08:38:46 +01:00
parent 591523e473
commit f1620abfad

View File

@ -744,7 +744,17 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
if (!font_desc) if (!font_desc)
{ {
GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
GtkWidgetPath *widget_path;
style = gtk_style_context_new (); style = gtk_style_context_new ();
gtk_style_context_set_screen (style, screen);
widget_path = gtk_widget_path_new ();
gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
gtk_style_context_set_path (style, widget_path);
gtk_widget_path_free (widget_path);
gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL); gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
font_desc = (const PangoFontDescription *) free_font_desc; font_desc = (const PangoFontDescription *) free_font_desc;
} }