[gnome-shell/gnome-3-36] st/theme: Unref CRStylesheet after removing old theme nodes
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-36] st/theme: Unref CRStylesheet after removing old theme nodes
- Date: Fri, 1 May 2020 14:32:48 +0000 (UTC)
commit 118676bffb44eac5e8caff159c2306e7bef4deba
Author: Jonas Dreßler <verdre v0yd nl>
Date: Thu Apr 30 20:23:52 2020 +0000
st/theme: Unref CRStylesheet after removing old theme nodes
Since we now remove all theme nodes on a stylesheet change (ie.
StTheme's "custom-stylesheets-changed" signal) instead of only
invalidating them, those nodes may not be accessed anymore as soon as
"custom-stylesheets-changed" is emitted.
It turned out though that when comparing them to the newly generated
nodes in `st_widget_recompute_style()` using the
`st_theme_node_paint/geometry_equal()` functions, the properties of the
old nodes will still be accessed, causing a crash since the
CRDeclarations are already freed.
To fix that, keep the reference to the CRStylesheet, which owns the
CRDeclarations used by the theme nodes, around a bit longer, so it's
still possible to access the CRDeclarations inside the
"custom-stylesheets-changed" signal handler. This allows us to compare
the old theme nodes to the new ones since the CSS properties of both are
still valid.
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2709
(cherry picked from commit e06109c23ce2a6dd53d32c26a89ab46a952d7373)
src/st/st-theme.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/st/st-theme.c b/src/st/st-theme.c
index 0d2d2eeace..7ccf7b5bad 100644
--- a/src/st/st-theme.c
+++ b/src/st/st-theme.c
@@ -287,8 +287,10 @@ st_theme_unload_stylesheet (StTheme *theme,
theme->custom_stylesheets = g_slist_remove (theme->custom_stylesheets, stylesheet);
g_hash_table_remove (theme->stylesheets_by_file, file);
g_hash_table_remove (theme->files_by_stylesheet, stylesheet);
- cr_stylesheet_unref (stylesheet);
+
g_signal_emit (theme, signals[STYLESHEETS_CHANGED], 0);
+
+ cr_stylesheet_unref (stylesheet);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]