checkbutton: fix critical when setting use-underline

This needs to make sure that we've created the label before applying the
setting on a child widget.

Fixes #4934
This commit is contained in:
Christian Hergert 2022-05-17 12:28:25 -07:00
parent 5f469a0d2d
commit b9574e119b

View File

@ -959,7 +959,7 @@ gtk_check_button_set_label (GtkCheckButton *self,
gtk_label_set_use_underline (GTK_LABEL (child), priv->use_underline); gtk_label_set_use_underline (GTK_LABEL (child), priv->use_underline);
gtk_check_button_real_set_child (self, GTK_WIDGET (child), LABEL_CHILD); gtk_check_button_real_set_child (self, GTK_WIDGET (child), LABEL_CHILD);
} }
gtk_widget_add_css_class (GTK_WIDGET (self), "text-button"); gtk_widget_add_css_class (GTK_WIDGET (self), "text-button");
gtk_label_set_label (GTK_LABEL (priv->child), label); gtk_label_set_label (GTK_LABEL (priv->child), label);
} }
@ -1099,7 +1099,7 @@ gtk_check_button_set_use_underline (GtkCheckButton *self,
return; return;
priv->use_underline = setting; priv->use_underline = setting;
if (priv->child_type == LABEL_CHILD) if (priv->child_type == LABEL_CHILD && priv->child != NULL)
gtk_label_set_use_underline (GTK_LABEL (priv->child), priv->use_underline); gtk_label_set_use_underline (GTK_LABEL (priv->child), priv->use_underline);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_USE_UNDERLINE]); g_object_notify_by_pspec (G_OBJECT (self), props[PROP_USE_UNDERLINE]);