1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
From d5329045423fa60e543a3b83227dbe3ef6dd51c1 Mon Sep 17 00:00:00 2001
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
Date: Thu, 17 Apr 2025 17:38:21 +0800
Subject: [PATCH 1/4] st/theme-node: Remove unused field
---
src/st/st-theme-node-private.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/st/st-theme-node-private.h b/src/st/st-theme-node-private.h
index d95284e201a..0fb3646a3e7 100644
--- a/src/st/st-theme-node-private.h
+++ b/src/st/st-theme-node-private.h
@@ -104,8 +104,6 @@ struct _StThemeNode {
int box_shadow_min_width;
int box_shadow_min_height;
- guint stylesheets_changed_id;
-
CoglTexture *border_slices_texture;
CoglPipeline *border_slices_pipeline;
CoglTexture *background_texture;
--
GitLab
From 07a5513fcb2580c5ea9808c553637155aa3b2217 Mon Sep 17 00:00:00 2001
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
Date: Thu, 28 Mar 2024 14:45:26 +0800
Subject: [PATCH 2/4] st/theme-node: Forget properties cache before unref'ing
the theme
Which the properties point into.
---
src/st/st-theme-node.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index 4e0111d4f94..8fbb71a1074 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -102,6 +102,7 @@ st_theme_node_dispose (GObject *gobject)
st_theme_node_paint_state_free (&node->cached_state);
+ maybe_free_properties (node);
g_clear_object (&node->theme);
G_OBJECT_CLASS (st_theme_node_parent_class)->dispose (gobject);
@@ -117,8 +118,6 @@ st_theme_node_finalize (GObject *object)
g_strfreev (node->pseudo_classes);
g_free (node->inline_style);
- maybe_free_properties (node);
-
g_clear_pointer (&node->font_desc, pango_font_description_free);
g_clear_pointer (&node->box_shadow, st_shadow_unref);
--
GitLab
From f4aab0a2ddea3b7a9d49c48f3ef42b80bde5b6d4 Mon Sep 17 00:00:00 2001
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
Date: Thu, 17 Apr 2025 17:19:16 +0800
Subject: [PATCH 3/4] st/theme-node: Make maybe_free_properties a protected
function
For reuse elsewhere in ST.
---
src/st/st-theme-node-private.h | 1 +
src/st/st-theme-node.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/st/st-theme-node-private.h b/src/st/st-theme-node-private.h
index 0fb3646a3e7..958289311c3 100644
--- a/src/st/st-theme-node-private.h
+++ b/src/st/st-theme-node-private.h
@@ -119,5 +119,6 @@ void _st_theme_node_ensure_background (StThemeNode *node);
void _st_theme_node_ensure_geometry (StThemeNode *node);
void _st_theme_node_apply_margins (StThemeNode *node,
ClutterActor *actor);
+void _st_theme_node_maybe_free_properties (StThemeNode *node);
G_END_DECLS
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index 8fbb71a1074..3273c0e418b 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -59,8 +59,8 @@ st_theme_node_class_init (StThemeNodeClass *klass)
object_class->finalize = st_theme_node_finalize;
}
-static void
-maybe_free_properties (StThemeNode *node)
+void
+_st_theme_node_maybe_free_properties (StThemeNode *node)
{
if (node->properties)
{
@@ -102,7 +102,7 @@ st_theme_node_dispose (GObject *gobject)
st_theme_node_paint_state_free (&node->cached_state);
- maybe_free_properties (node);
+ _st_theme_node_maybe_free_properties (node);
g_clear_object (&node->theme);
G_OBJECT_CLASS (st_theme_node_parent_class)->dispose (gobject);
--
GitLab
From 73989bf793bae8d973f071f75502e6878e9d75f4 Mon Sep 17 00:00:00 2001
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
Date: Thu, 17 Apr 2025 17:32:22 +0800
Subject: [PATCH 4/4] st/theme-context: Forget properties cache on node removal
Which means when the stylesheets change.
To avoid `node->properties` pointing to freed memory after each
`st_theme_unload_stylesheet`, flush the cache that is `node->properties`.
They will be reloaded as soon as they are required again.
Why not just fix Croco? Croco does not use proper reference counting
everywhere it should, and retrofitting it would be difficult due to the
recursive nature of `CRDeclaration`.
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7339
... but mostly reported in
https://github.com/micheleg/dash-to-dock/issues/2179 and its duplicates.
---
src/st/st-theme-context.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/st/st-theme-context.c b/src/st/st-theme-context.c
index eb24212e128..9509bf4ae6e 100644
--- a/src/st/st-theme-context.c
+++ b/src/st/st-theme-context.c
@@ -169,6 +169,13 @@ st_theme_context_class_init (StThemeContextClass *klass)
G_TYPE_NONE, 0);
}
+static void
+forget_node (StThemeNode *node)
+{
+ _st_theme_node_maybe_free_properties (node);
+ g_object_unref (node);
+}
+
static void
st_theme_context_init (StThemeContext *context)
{
@@ -189,7 +196,8 @@ st_theme_context_init (StThemeContext *context)
context->nodes = g_hash_table_new_full ((GHashFunc) st_theme_node_hash,
(GEqualFunc) st_theme_node_equal,
- g_object_unref, NULL);
+ (GDestroyNotify) forget_node,
+ NULL);
context->scale_factor = 1;
update_accent_colors (context);
@@ -599,4 +607,4 @@ st_theme_context_get_resolution (StThemeContext *context)
g_return_val_if_fail (ST_IS_THEME_CONTEXT (context), -1);
return clutter_backend_get_resolution (context->clutter_backend);
-}
\ No newline at end of file
+}
--
GitLab
|