From fb04dafb0bc2585ba7ea119e527644f9a7a85326 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 30 Apr 2019 14:42:59 +0200 Subject: [PATCH] st: Use g_signal_handler_disconnect() to disconnect from StTheme With a high enough amount of actors, there may be enough theme nodes and signal connections on StTheme::custom-stylesheets-changed that g_signal_handlers_disconnect_by*() on dispose becomes expensive, this may become a surprisingly hot spot in StWidget::style-changed. Keep the handler ID around and use g_signal_handler_disconnect() to avoid linear lookups for the matching func/data. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/524 --- src/st/st-theme-node-private.h | 2 ++ src/st/st-theme-node.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/st/st-theme-node-private.h b/src/st/st-theme-node-private.h index 2e6b232f6..47be65dba 100644 --- a/src/st/st-theme-node-private.h +++ b/src/st/st-theme-node-private.h @@ -107,6 +107,8 @@ struct _StThemeNode { int box_shadow_min_width; int box_shadow_min_height; + guint stylesheets_changed_id; + CoglPipeline *border_slices_texture; CoglPipeline *border_slices_pipeline; CoglPipeline *background_texture; diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c index 8a6ebf03f..8e910f831 100644 --- a/src/st/st-theme-node.c +++ b/src/st/st-theme-node.c @@ -111,9 +111,11 @@ st_theme_node_dispose (GObject *gobject) node->icon_colors = NULL; } - if (node->theme) - g_signal_handlers_disconnect_by_func (node->theme, - on_custom_stylesheets_changed, node); + if (node->theme && node->stylesheets_changed_id) + { + g_signal_handler_disconnect (node->theme, node->stylesheets_changed_id); + node->stylesheets_changed_id = 0; + } st_theme_node_paint_state_free (&node->cached_state); @@ -230,8 +232,9 @@ st_theme_node_new (StThemeContext *context, if (theme != NULL) { node->theme = g_object_ref (theme); - g_signal_connect (node->theme, "custom-stylesheets-changed", - G_CALLBACK (on_custom_stylesheets_changed), node); + node->stylesheets_changed_id = + g_signal_connect (node->theme, "custom-stylesheets-changed", + G_CALLBACK (on_custom_stylesheets_changed), node); } node->element_type = element_type;