Skip to content

Commit 2bf2942

Browse files
committed
st-theme-node.c: Fix a leak when falling back to the default theme
on 'important' ui elements. _st_theme_get_matched_properties always returns a new GPtrArray, even if it's empty. It can be reused in the fallback lookup.
1 parent a109ce9 commit 2bf2942

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/st/st-theme-node.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,10 @@ ensure_properties (StThemeNode *node)
468468
if (node->theme)
469469
{
470470
properties = _st_theme_get_matched_properties (node->theme, node);
471-
if ((!properties || properties->len == 0) && node->important)
472-
properties = _st_theme_get_matched_properties_fallback (node->theme, node);
471+
if (properties->len == 0 && node->important)
472+
{
473+
properties = _st_theme_get_matched_properties_fallback (node->theme, node, properties);
474+
}
473475
}
474476

475477
if (node->inline_style)

src/st/st-theme-private.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ GPtrArray *_st_theme_get_matched_properties (StTheme *theme,
3030
StThemeNode *node);
3131

3232
GPtrArray *_st_theme_get_matched_properties_fallback (StTheme *theme,
33-
StThemeNode *node);
33+
StThemeNode *node,
34+
GPtrArray *props);
3435

3536
/* Resolve an URL from the stylesheet to a filename */
3637
GFile *_st_theme_resolve_url (StTheme *theme,

src/st/st-theme.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,15 +1062,12 @@ _st_theme_get_matched_properties (StTheme *theme,
10621062

10631063
GPtrArray *
10641064
_st_theme_get_matched_properties_fallback (StTheme *theme,
1065-
StThemeNode *node)
1065+
StThemeNode *node,
1066+
GPtrArray *props)
10661067
{
1067-
GPtrArray *props;
1068-
10691068
g_return_val_if_fail (ST_IS_THEME (theme), NULL);
10701069
g_return_val_if_fail (ST_IS_THEME_NODE (node), NULL);
10711070

1072-
props = g_ptr_array_new ();
1073-
10741071
if (theme->fallback_cr_stylesheet)
10751072
add_matched_properties (theme, theme->fallback_cr_stylesheet, node, props);
10761073

0 commit comments

Comments
 (0)