summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <[email protected]>2020-07-20 13:13:03 +0200
committerPablo Barciela <[email protected]>2020-08-03 13:46:34 +0200
commit1d48043b7b8fa0dfbe865ae94eff047f654f4931 (patch)
tree83037d0f89930ebb8218f6c29fb9955b15cf6925
parent96b1172619cc4bb044e6ba30210800b645651002 (diff)
downloadmate-panel-1d48043b7b8fa0dfbe865ae94eff047f654f4931.tar.bz2
mate-panel-1d48043b7b8fa0dfbe865ae94eff047f654f4931.tar.xz
mate-panel-applet: Fix leaking GVariantBuilder
And use stack-allocated GVariantBuilder for temporary storage.
-rw-r--r--libmate-panel-applet/mate-panel-applet.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c
index adb1d467..ea9031ca 100644
--- a/libmate-panel-applet/mate-panel-applet.c
+++ b/libmate-panel-applet/mate-panel-applet.c
@@ -206,14 +206,14 @@ mate_panel_applet_set_flags (MatePanelApplet *applet,
g_object_notify (G_OBJECT (applet), "flags");
if (applet->priv->connection) {
- GVariantBuilder *builder;
- GVariantBuilder *invalidated_builder;
+ GVariantBuilder builder;
+ GVariantBuilder invalidated_builder;
GError *error = NULL;
- builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
- invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
- g_variant_builder_add (builder, "{sv}", "Flags",
+ g_variant_builder_add (&builder, "{sv}", "Flags",
g_variant_new_uint32 (applet->priv->flags));
g_dbus_connection_emit_signal (applet->priv->connection,
@@ -223,14 +223,16 @@ mate_panel_applet_set_flags (MatePanelApplet *applet,
"PropertiesChanged",
g_variant_new ("(sa{sv}as)",
MATE_PANEL_APPLET_INTERFACE,
- builder,
- invalidated_builder),
+ &builder,
+ &invalidated_builder),
&error);
if (error) {
g_printerr ("Failed to send signal PropertiesChanged::Flags: %s\n",
error->message);
g_error_free (error);
}
+ g_variant_builder_clear (&builder);
+ g_variant_builder_clear (&invalidated_builder);
}
}
@@ -295,18 +297,18 @@ mate_panel_applet_set_size_hints (MatePanelApplet *applet,
g_object_notify (G_OBJECT (applet), "size-hints");
if (applet->priv->connection) {
- GVariantBuilder *builder;
- GVariantBuilder *invalidated_builder;
+ GVariantBuilder builder;
+ GVariantBuilder invalidated_builder;
GVariant **children;
GError *error = NULL;
- builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
- invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
children = g_new (GVariant *, applet->priv->size_hints_len);
for (i = 0; i < n_elements; i++)
children[i] = g_variant_new_int32 (applet->priv->size_hints[i]);
- g_variant_builder_add (builder, "{sv}", "SizeHints",
+ g_variant_builder_add (&builder, "{sv}", "SizeHints",
g_variant_new_array (G_VARIANT_TYPE_INT32,
children, applet->priv->size_hints_len));
g_free (children);
@@ -318,14 +320,16 @@ mate_panel_applet_set_size_hints (MatePanelApplet *applet,
"PropertiesChanged",
g_variant_new ("(sa{sv}as)",
MATE_PANEL_APPLET_INTERFACE,
- builder,
- invalidated_builder),
+ &builder,
+ &invalidated_builder),
&error);
if (error) {
g_printerr ("Failed to send signal PropertiesChanged::SizeHints: %s\n",
error->message);
g_error_free (error);
}
+ g_variant_builder_clear (&builder);
+ g_variant_builder_clear (&invalidated_builder);
}
}