mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-21 14:24:19 +00:00
application: Plug a leak
The key returned by g_variant_iter_next() should be freed as well. Also, clean up the coding style a bit.
This commit is contained in:
parent
5f4309be96
commit
3e1b82336c
@ -71,6 +71,7 @@
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
|
||||||
PROP_WINDOW
|
PROP_WINDOW
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -142,6 +143,8 @@ gtk_application_default_prepare_activation (GApplication *application,
|
|||||||
if (strcmp (key, "startup-notification-id") == 0 &&
|
if (strcmp (key, "startup-notification-id") == 0 &&
|
||||||
g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
|
g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
|
||||||
gdk_notify_startup_complete_with_id (g_variant_get_string (value, NULL));
|
gdk_notify_startup_complete_with_id (g_variant_get_string (value, NULL));
|
||||||
|
|
||||||
|
g_free (key);
|
||||||
g_variant_unref (value);
|
g_variant_unref (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,26 +153,25 @@ gtk_application_default_prepare_activation (GApplication *application,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_application_default_activated (GtkApplication *application,
|
gtk_application_default_activated (GtkApplication *application,
|
||||||
GVariant *arguments)
|
GVariant *arguments)
|
||||||
{
|
{
|
||||||
GtkApplication *app = GTK_APPLICATION (application);
|
GtkApplicationPrivate *priv = application->priv;
|
||||||
|
|
||||||
/* TODO: should we raise the last focused window instead ? */
|
/* TODO: should we raise the last focused window instead ? */
|
||||||
if (app->priv->default_window != NULL)
|
if (priv->default_window != NULL)
|
||||||
gtk_window_present (app->priv->default_window);
|
gtk_window_present (priv->default_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_application_default_action (GtkApplication *application,
|
gtk_application_default_action (GtkApplication *application,
|
||||||
const gchar *action_name)
|
const gchar *action_name)
|
||||||
{
|
{
|
||||||
|
GtkApplicationPrivate *priv = application->priv;
|
||||||
GtkAction *action;
|
GtkAction *action;
|
||||||
|
|
||||||
action = gtk_action_group_get_action (application->priv->main_actions, action_name);
|
action = gtk_action_group_get_action (priv->main_actions, action_name);
|
||||||
if (action)
|
if (action)
|
||||||
{
|
gtk_action_activate (action);
|
||||||
gtk_action_activate (action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWindow *
|
static GtkWindow *
|
||||||
@ -265,6 +267,7 @@ gtk_application_new (const gchar *appid,
|
|||||||
argc_for_app = *argc;
|
argc_for_app = *argc;
|
||||||
else
|
else
|
||||||
argc_for_app = 0;
|
argc_for_app = 0;
|
||||||
|
|
||||||
if (argv)
|
if (argv)
|
||||||
argv_for_app = *argv;
|
argv_for_app = *argv;
|
||||||
else
|
else
|
||||||
@ -278,7 +281,7 @@ gtk_application_new (const gchar *appid,
|
|||||||
"application-id", appid,
|
"application-id", appid,
|
||||||
"argv", argv_variant,
|
"argv", argv_variant,
|
||||||
NULL);
|
NULL);
|
||||||
if (!app)
|
if (app == NULL)
|
||||||
{
|
{
|
||||||
g_error ("%s", error->message);
|
g_error ("%s", error->message);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
@ -326,6 +329,7 @@ gtk_application_set_action_group (GtkApplication *app,
|
|||||||
GList *actions, *iter;
|
GList *actions, *iter;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_APPLICATION (app));
|
g_return_if_fail (GTK_IS_APPLICATION (app));
|
||||||
|
g_return_if_fail (GTK_IS_ACTION_GROUP (group));
|
||||||
g_return_if_fail (app->priv->main_actions == NULL);
|
g_return_if_fail (app->priv->main_actions == NULL);
|
||||||
|
|
||||||
app->priv->main_actions = g_object_ref (group);
|
app->priv->main_actions = g_object_ref (group);
|
||||||
@ -510,10 +514,9 @@ gtk_application_quit (GtkApplication *app)
|
|||||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
||||||
g_variant_builder_add (&builder, "{sv}",
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
"timestamp",
|
"timestamp",
|
||||||
g_variant_new ("u",
|
g_variant_new ("u", gtk_get_current_event_time ()));
|
||||||
gtk_get_current_event_time ()));
|
|
||||||
platform_data = g_variant_builder_end (&builder);
|
platform_data = g_variant_builder_end (&builder);
|
||||||
|
|
||||||
g_application_quit_with_data (G_APPLICATION (app), platform_data);
|
g_application_quit_with_data (G_APPLICATION (app), platform_data);
|
||||||
|
|
||||||
g_variant_unref (platform_data);
|
g_variant_unref (platform_data);
|
||||||
|
Loading…
Reference in New Issue
Block a user