summaryrefslogtreecommitdiff
path: root/gtk/gtkstackswitcher.c
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2021-06-02 10:19:42 -0700
committerChristian Hergert <chergert@redhat.com>2021-06-02 10:20:32 -0700
commitc2ca246aee0f9ebe01a26c18f116216621af0e26 (patch)
treeeebfedd46a1654a9824980eb224e08443cc48d32 /gtk/gtkstackswitcher.c
parent80c33ca2ddea9116b869302e9375de75e2dca0d9 (diff)
downloadgtk+-c2ca246aee0f9ebe01a26c18f116216621af0e26.tar.gz
stackswitcher: clear timer when widget id disposed
If the widget is disposed while the cursor has a drag timeout queued, it can activate after finalization.
Diffstat (limited to 'gtk/gtkstackswitcher.c')
-rw-r--r--gtk/gtkstackswitcher.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index 502f3f3037..ffbfff98c2 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -226,6 +226,13 @@ gtk_stack_switcher_switch_timeout (gpointer data)
}
static void
+clear_timer (gpointer data)
+{
+ if (data)
+ g_source_remove (GPOINTER_TO_UINT (data));
+}
+
+static void
gtk_stack_switcher_drag_enter (GtkDropControllerMotion *motion,
double x,
double y,
@@ -239,7 +246,7 @@ gtk_stack_switcher_drag_enter (GtkDropControllerMotion *motion,
gtk_stack_switcher_switch_timeout,
button);
g_source_set_name_by_id (switch_timer, "[gtk] gtk_stack_switcher_switch_timeout");
- g_object_set_data (G_OBJECT (button), "-gtk-switch-timer", GUINT_TO_POINTER (switch_timer));
+ g_object_set_data_full (G_OBJECT (button), "-gtk-switch-timer", GUINT_TO_POINTER (switch_timer), clear_timer);
}
}