stylecontext: Make font hack not crash
It's a lot uglier now, but it shouldn't crash anymore. We must update the font description for animations, but we can't free it on query, because some paths call gtk_style_context_get_font() twice in a row without stopping the use of the first call. So us just creating a new font description all the time and unreffing the old one is not a good idea. So we just mere the new one into the old one. https://bugzilla.gnome.org/show_bug.cgi?id=691186
This commit is contained in:
parent
15129ae170
commit
8a644e4f16
@ -3537,7 +3537,7 @@ gtk_style_context_get_font (GtkStyleContext *context,
|
|||||||
{
|
{
|
||||||
GtkStyleContextPrivate *priv;
|
GtkStyleContextPrivate *priv;
|
||||||
StyleData *data;
|
StyleData *data;
|
||||||
PangoFontDescription *description;
|
PangoFontDescription *description, *previous;
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
|
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
|
||||||
|
|
||||||
@ -3549,10 +3549,22 @@ gtk_style_context_get_font (GtkStyleContext *context,
|
|||||||
/* Yuck, fonts are created on-demand but we don't return a ref.
|
/* Yuck, fonts are created on-demand but we don't return a ref.
|
||||||
* Do bad things to achieve this requirement */
|
* Do bad things to achieve this requirement */
|
||||||
gtk_style_context_get (context, state, "font", &description, NULL);
|
gtk_style_context_get (context, state, "font", &description, NULL);
|
||||||
|
|
||||||
|
previous = g_object_get_data (G_OBJECT (data->store), "font-cache-for-get_font");
|
||||||
|
|
||||||
|
if (previous)
|
||||||
|
{
|
||||||
|
pango_font_description_merge (previous, description, TRUE);
|
||||||
|
pango_font_description_free (description);
|
||||||
|
description = previous;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
g_object_set_data_full (G_OBJECT (data->store),
|
g_object_set_data_full (G_OBJECT (data->store),
|
||||||
"font-cache-for-get_font",
|
"font-cache-for-get_font",
|
||||||
description,
|
description,
|
||||||
(GDestroyNotify) pango_font_description_free);
|
(GDestroyNotify) pango_font_description_free);
|
||||||
|
}
|
||||||
|
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user