forked from AuroraMiddleware/gtk
scale: Fix sporadic criticals
gtk_css_node_update_layout_attributes can cause us to free priv->layout, and then bad things happen. Therefore, we must call that function on a new layout *before* setting priv->layout.
This commit is contained in:
parent
3cfd1e1f52
commit
eaabc3722e
@ -2020,23 +2020,26 @@ gtk_scale_get_layout (GtkScale *scale)
|
||||
|
||||
if (!priv->layout && priv->draw_value)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
int min_layout_width;
|
||||
|
||||
priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL);
|
||||
gtk_css_node_update_layout_attributes (gtk_css_gadget_get_node (priv->value_gadget), priv->layout);
|
||||
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL);
|
||||
gtk_css_node_update_layout_attributes (gtk_css_gadget_get_node (priv->value_gadget), layout);
|
||||
gtk_css_gadget_get_preferred_size (priv->value_gadget,
|
||||
GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
&min_layout_width, NULL,
|
||||
NULL, NULL);
|
||||
pango_layout_set_width (priv->layout, min_layout_width * PANGO_SCALE);
|
||||
|
||||
pango_layout_set_width (layout, min_layout_width * PANGO_SCALE);
|
||||
|
||||
if (priv->value_pos == GTK_POS_LEFT)
|
||||
pango_layout_set_alignment (priv->layout, PANGO_ALIGN_RIGHT);
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
|
||||
else if (priv->value_pos == GTK_POS_RIGHT)
|
||||
pango_layout_set_alignment (priv->layout, PANGO_ALIGN_LEFT);
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
|
||||
else
|
||||
pango_layout_set_alignment (priv->layout, PANGO_ALIGN_CENTER);
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
|
||||
|
||||
priv->layout = layout;
|
||||
}
|
||||
|
||||
if (priv->draw_value)
|
||||
|
Loading…
Reference in New Issue
Block a user