progressbar: Fix up acessible state handling

We must initialize the properties in init, since they
are expected to be there ab initio, and we can't call
gtk_accessible_update_property from finalize - it causes
us to recreate an at context and badness follows.
This commit is contained in:
Matthias Clasen 2020-07-27 19:24:49 -04:00
parent d3a8597a93
commit ec5829c401

View File

@ -154,6 +154,7 @@ static void gtk_progress_bar_get_property (GObject *object,
static void gtk_progress_bar_act_mode_enter (GtkProgressBar *progress); static void gtk_progress_bar_act_mode_enter (GtkProgressBar *progress);
static void gtk_progress_bar_act_mode_leave (GtkProgressBar *progress); static void gtk_progress_bar_act_mode_leave (GtkProgressBar *progress);
static void gtk_progress_bar_finalize (GObject *object); static void gtk_progress_bar_finalize (GObject *object);
static void gtk_progress_bar_dispose (GObject *object);
static void gtk_progress_bar_set_orientation (GtkProgressBar *progress, static void gtk_progress_bar_set_orientation (GtkProgressBar *progress,
GtkOrientation orientation); GtkOrientation orientation);
static void gtk_progress_bar_direction_changed (GtkWidget *widget, static void gtk_progress_bar_direction_changed (GtkWidget *widget,
@ -173,6 +174,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
gobject_class->set_property = gtk_progress_bar_set_property; gobject_class->set_property = gtk_progress_bar_set_property;
gobject_class->get_property = gtk_progress_bar_get_property; gobject_class->get_property = gtk_progress_bar_get_property;
gobject_class->dispose = gtk_progress_bar_dispose;
gobject_class->finalize = gtk_progress_bar_finalize; gobject_class->finalize = gtk_progress_bar_finalize;
widget_class->direction_changed = gtk_progress_bar_direction_changed; widget_class->direction_changed = gtk_progress_bar_direction_changed;
@ -460,6 +462,12 @@ gtk_progress_bar_init (GtkProgressBar *pbar)
pbar->orientation = GTK_ORIENTATION_VERTICAL; /* Just to force an update... */ pbar->orientation = GTK_ORIENTATION_VERTICAL; /* Just to force an update... */
gtk_progress_bar_set_orientation (pbar, GTK_ORIENTATION_HORIZONTAL); gtk_progress_bar_set_orientation (pbar, GTK_ORIENTATION_HORIZONTAL);
gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation); gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation);
gtk_accessible_update_property (GTK_ACCESSIBLE (pbar),
GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 1.0,
GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 0.0,
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, 0.0,
-1);
} }
static void static void
@ -556,19 +564,26 @@ gtk_progress_bar_new (void)
} }
static void static void
gtk_progress_bar_finalize (GObject *object) gtk_progress_bar_dispose (GObject *object)
{ {
GtkProgressBar *pbar = GTK_PROGRESS_BAR (object); GtkProgressBar *pbar = GTK_PROGRESS_BAR (object);
if (pbar->activity_mode) if (pbar->activity_mode)
gtk_progress_bar_act_mode_leave (pbar); gtk_progress_bar_act_mode_leave (pbar);
g_free (pbar->text);
g_clear_pointer (&pbar->label, gtk_widget_unparent); g_clear_pointer (&pbar->label, gtk_widget_unparent);
g_clear_pointer (&pbar->progress_widget, gtk_widget_unparent);
g_clear_pointer (&pbar->trough_widget, gtk_widget_unparent);
gtk_widget_unparent (pbar->progress_widget); G_OBJECT_CLASS (gtk_progress_bar_parent_class)->dispose (object);
gtk_widget_unparent (pbar->trough_widget); }
static void
gtk_progress_bar_finalize (GObject *object)
{
GtkProgressBar *pbar = GTK_PROGRESS_BAR (object);
g_free (pbar->text);
G_OBJECT_CLASS (gtk_progress_bar_parent_class)->finalize (object); G_OBJECT_CLASS (gtk_progress_bar_parent_class)->finalize (object);
} }