summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Borelli <pborelli@gnome.org>2014-02-16 22:22:59 +0100
committerMatthias Clasen <mclasen@redhat.com>2015-06-21 11:32:31 -0400
commit4e155d784dda384cd4bba6653134b1a0542ee569 (patch)
treea6329c4493bb72ee90e2109eb8ee84e9a89e73a4
parent3b43951ba4da9869e5f79f674e8c8a2fc16c78a9 (diff)
downloadgtk+-4e155d784dda384cd4bba6653134b1a0542ee569.tar.gz
Avoid spurious operations on destroy
When the stack is destroyed we do not want to waste time running animations and notifying listeners about which is our current visible child. This is not only an optimization, but it is important for the stack switcher widgets: since they are in another branch of the hieratchy we do not want to get notifications while the stack is being destroyed. Based on a patch by Paolo Borelli https://bugzilla.gnome.org/show_bug.cgi?id=724506
-rw-r--r--gtk/gtkstack.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index 7752689991..e1e4f3b444 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -141,6 +141,8 @@ typedef struct {
gint last_visible_widget_height;
GtkStackTransitionType active_transition_type;
+
+ gboolean destroying;
} GtkStackPrivate;
static GParamSpec *stack_props[LAST_PROP] = { NULL, };
@@ -174,6 +176,7 @@ static void gtk_stack_get_preferred_width_for_height (GtkWidget *widget,
gint height,
gint *minimum_width,
gint *natural_width);
+static void gtk_stack_destroy (GtkWidget *widget);
static void gtk_stack_finalize (GObject *obj);
static void gtk_stack_get_property (GObject *object,
guint property_id,
@@ -399,6 +402,7 @@ gtk_stack_class_init (GtkStackClass *klass)
widget_class->get_preferred_width = gtk_stack_get_preferred_width;
widget_class->get_preferred_width_for_height = gtk_stack_get_preferred_width_for_height;
widget_class->compute_expand = gtk_stack_compute_expand;
+ widget_class->destroy = gtk_stack_destroy;
container_class->add = gtk_stack_add;
container_class->remove = gtk_stack_remove;
@@ -1012,6 +1016,11 @@ set_visible_child (GtkStack *stack,
GtkWidget *focus;
gboolean contains_focus = FALSE;
+ /* if we are being destroyed, do not bother with transitions
+ * and notifications */
+ if (priv->destroying)
+ return;
+
/* If none, pick first visible */
if (child_info == NULL)
{
@@ -1843,6 +1852,17 @@ gtk_stack_compute_expand (GtkWidget *widget,
}
static void
+gtk_stack_destroy (GtkWidget *widget)
+{
+ GtkStack *stack = GTK_STACK (widget);
+ GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
+
+ priv->destroying = TRUE;
+
+ GTK_WIDGET_CLASS (gtk_stack_parent_class)->destroy (widget);
+}
+
+static void
gtk_stack_draw_crossfade (GtkWidget *widget,
cairo_t *cr)
{