From 3bfb6d6b5b10c2ef34414763f975eed2525c3d2e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 20:47:53 -0600 Subject: Fixing some of the variant usage to free strings appropriately --- src/indicator-application.c | 82 +++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 8b28ebc..577008d 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -802,23 +802,32 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, } if (g_strcmp0(signal_name, "ApplicationAdded") == 0) { - const gchar * iconname; + gchar * iconname; gint position; - const gchar * dbusaddress; - const gchar * dbusobject; - const gchar * icon_theme_path; - const gchar * label; - const gchar * guide; - const gchar * accessible_desc; - const gchar * hint; - const gchar * title; - g_variant_get (parameters, "(&si&s&o&s&s&s&s&s&s)", &iconname, + gchar * dbusaddress; + gchar * dbusobject; + gchar * icon_theme_path; + gchar * label; + gchar * guide; + gchar * accessible_desc; + gchar * hint; + gchar * title; + g_variant_get (parameters, "(sisossssss)", &iconname, &position, &dbusaddress, &dbusobject, &icon_theme_path, &label, &guide, &accessible_desc, &hint, &title); application_added(self, iconname, position, dbusaddress, dbusobject, icon_theme_path, label, guide, accessible_desc, hint); + g_free(iconname); + g_free(dbusaddress); + g_free(dbusobject); + g_free(icon_theme_path); + g_free(label); + g_free(guide); + g_free(accessible_desc); + g_free(hint); + g_free(title); } else if (g_strcmp0(signal_name, "ApplicationRemoved") == 0) { gint position; @@ -827,23 +836,28 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, } else if (g_strcmp0(signal_name, "ApplicationIconChanged") == 0) { gint position; - const gchar * iconname; - const gchar * icondesc; - g_variant_get (parameters, "(i&s&s)", &position, &iconname, &icondesc); + gchar * iconname; + gchar * icondesc; + g_variant_get (parameters, "(iss)", &position, &iconname, &icondesc); application_icon_changed(self, position, iconname, icondesc); + g_free(iconname); + g_free(icondesc); } else if (g_strcmp0(signal_name, "ApplicationIconThemePathChanged") == 0) { gint position; - const gchar * icon_theme_path; - g_variant_get (parameters, "(i&s)", &position, &icon_theme_path); + gchar * icon_theme_path; + g_variant_get (parameters, "(is)", &position, &icon_theme_path); application_icon_theme_path_changed(self, position, icon_theme_path); + g_free(icon_theme_path); } else if (g_strcmp0(signal_name, "ApplicationLabelChanged") == 0) { gint position; - const gchar * label; - const gchar * guide; - g_variant_get (parameters, "(i&s&s)", &position, &label, &guide); + gchar * label; + gchar * guide; + g_variant_get (parameters, "(iss)", &position, &label, &guide); application_label_changed(self, position, label, guide); + g_free(label); + g_free(guide); } return; @@ -901,21 +915,33 @@ get_applications (GObject * obj, GAsyncResult * res, gpointer user_data) static void get_applications_helper (IndicatorApplication * self, GVariant * variant) { - const gchar * icon_name; + gchar * icon_name; gint position; - const gchar * dbus_address; - const gchar * dbus_object; - const gchar * icon_theme_path; - const gchar * label; - const gchar * guide; - const gchar * accessible_desc; - const gchar * hint; - const gchar * title; + gchar * dbus_address; + gchar * dbus_object; + gchar * icon_theme_path; + gchar * label; + gchar * guide; + gchar * accessible_desc; + gchar * hint; + gchar * title; g_variant_get(variant, "(sisossssss)", &icon_name, &position, &dbus_address, &dbus_object, &icon_theme_path, &label, &guide, &accessible_desc, &hint, &title); - return application_added(self, icon_name, position, dbus_address, dbus_object, icon_theme_path, label, guide, accessible_desc, hint); + application_added(self, icon_name, position, dbus_address, dbus_object, icon_theme_path, label, guide, accessible_desc, hint); + + g_free(icon_name); + g_free(dbus_address); + g_free(dbus_object); + g_free(icon_theme_path); + g_free(label); + g_free(guide); + g_free(accessible_desc); + g_free(hint); + g_free(title); + + return; } /* Unrefs a theme directory. This may involve removing it from -- cgit v1.2.3 From 11f93ebdf7936dbdbfac5b5d9bec89826884faf8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 20:49:23 -0600 Subject: Ignoring generated files --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index beef564..1290cba 100644 --- a/.bzrignore +++ b/.bzrignore @@ -112,3 +112,5 @@ bindings/mono/policy.0.0.appindicator-sharp.config bindings/mono/policy.0.0.appindicator-sharp.dll src/libapplication_la-generate-id.lo src/libappindicator_la-generate-id.lo +gen-notification-approver.xml.c +gen-notification-approver.xml.h -- cgit v1.2.3 From 79e3bfeacfc134a7a96b2a47b2ca3f285535262c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 20:55:43 -0600 Subject: Fixing variant usage --- src/application-service-appstore.c | 48 ++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 0548ced..587557e 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -268,8 +268,8 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, ApplicationServiceAppstore * service = APPLICATION_SERVICE_APPSTORE(user_data); GVariant * retval = NULL; Application *app = NULL; - const gchar *dbusaddress; - const gchar *dbusmenuobject; + gchar *dbusaddress; + gchar *dbusmenuobject; if (g_strcmp0(method, "GetApplications") == 0) { retval = get_applications(service); @@ -278,7 +278,7 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, gint delta; guint direction; - g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusmenuobject, + g_variant_get (params, "(ssiu)", &dbusaddress, &dbusmenuobject, &delta, &direction); switch (direction) { @@ -304,7 +304,7 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, } else if (g_strcmp0(method, "ApplicationSecondaryActivateEvent") == 0) { guint time; - g_variant_get (params, "(&s&su)", &dbusaddress, &dbusmenuobject, &time); + g_variant_get (params, "(ssu)", &dbusaddress, &dbusmenuobject, &time); app = find_application_by_menu(service, dbusaddress, dbusmenuobject); if (app != NULL && app->dbus_proxy != NULL) { @@ -316,6 +316,9 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, g_warning("Calling method '%s' on the indicator service and it's unknown", method); } + g_free(dbusaddress); + g_free(dbusmenuobject); + g_dbus_method_invocation_return_value(invocation, retval); return; } @@ -1096,11 +1099,13 @@ name_changed (GDBusConnection * connection, const gchar * sender_name, { Application * app = (Application *)user_data; - const gchar * new_name; - g_variant_get(parameters, "(&s&s&s)", NULL, NULL, &new_name); + gchar * new_name; + g_variant_get(parameters, "(sss)", NULL, NULL, &new_name); if (new_name == NULL || new_name[0] == 0) application_died(app); + + g_free(new_name); } /* Callback from trying to create the proxy for the app. */ @@ -1223,19 +1228,23 @@ app_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name get_all_properties(app); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_STATUS) == 0) { - const gchar * status; - g_variant_get(parameters, "(&s)", &status); + gchar * status; + g_variant_get(parameters, "(s)", &status); new_status(app, status); + g_free(status); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH) == 0) { - const gchar * icon_theme_path; - g_variant_get(parameters, "(&s)", &icon_theme_path); + gchar * icon_theme_path; + g_variant_get(parameters, "(s)", &icon_theme_path); new_icon_theme_path(app, icon_theme_path); + g_free(icon_theme_path); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_LABEL) == 0) { - const gchar * label, * guide; - g_variant_get(parameters, "(&s&s)", &label, &guide); + gchar * label, * guide; + g_variant_get(parameters, "(ss)", &label, &guide); new_label(app, label, guide); + g_free(label); + g_free(guide); } return; @@ -1560,13 +1569,16 @@ approver_name_changed (GDBusConnection * connection, const gchar * sender_name, Approver * approver = (Approver *)user_data; ApplicationServiceAppstore * appstore = approver->appstore; - const gchar * new_name; - g_variant_get(parameters, "(&s&s&s)", NULL, NULL, &new_name); + gchar * new_name; + g_variant_get(parameters, "(sss)", NULL, NULL, &new_name); if (new_name == NULL || new_name[0] == 0) { appstore->priv->approvers = g_list_remove(appstore->priv->approvers, approver); approver_free(approver, appstore); } + + g_free(new_name); + return; } /* Callback from trying to create the proxy for the approver. */ @@ -1632,10 +1644,12 @@ approver_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal if (g_strcmp0(signal_name, "ReviseJudgement") == 0) { gboolean approved; - const gchar * address; - const gchar * path; - g_variant_get(parameters, "(b&s&o)", &approved, &address, &path); + gchar * address; + gchar * path; + g_variant_get(parameters, "(bso)", &approved, &address, &path); approver_revise_judgement(approver, approved, address, path); + g_free(address); + g_free(path); } return; -- cgit v1.2.3 From 18b22173e0e0f07cdfe75bb3bd15ae7ad80e4e97 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 22:01:20 -0600 Subject: Ensuring that the values are initialized to NULL before using that later. --- src/application-service-appstore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 587557e..8b06eec 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -268,8 +268,8 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, ApplicationServiceAppstore * service = APPLICATION_SERVICE_APPSTORE(user_data); GVariant * retval = NULL; Application *app = NULL; - gchar *dbusaddress; - gchar *dbusmenuobject; + gchar *dbusaddress = NULL; + gchar *dbusmenuobject = NULL; if (g_strcmp0(method, "GetApplications") == 0) { retval = get_applications(service); -- cgit v1.2.3 From ee1ac0d31371b8c472c44715eb7dce36b2793cc5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 22:10:50 -0600 Subject: Make sure to initialize values before free'ing them --- src/application-service-appstore.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 8b06eec..c0ec327 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1228,19 +1228,19 @@ app_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name get_all_properties(app); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_STATUS) == 0) { - gchar * status; + gchar * status = NULL; g_variant_get(parameters, "(s)", &status); new_status(app, status); g_free(status); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH) == 0) { - gchar * icon_theme_path; + gchar * icon_theme_path = NULL; g_variant_get(parameters, "(s)", &icon_theme_path); new_icon_theme_path(app, icon_theme_path); g_free(icon_theme_path); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_LABEL) == 0) { - gchar * label, * guide; + gchar * label = NULL, * guide = NULL; g_variant_get(parameters, "(ss)", &label, &guide); new_label(app, label, guide); g_free(label); @@ -1569,7 +1569,7 @@ approver_name_changed (GDBusConnection * connection, const gchar * sender_name, Approver * approver = (Approver *)user_data; ApplicationServiceAppstore * appstore = approver->appstore; - gchar * new_name; + gchar * new_name = NULL; g_variant_get(parameters, "(sss)", NULL, NULL, &new_name); if (new_name == NULL || new_name[0] == 0) { @@ -1643,9 +1643,9 @@ approver_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal Approver * approver = (Approver *)user_data; if (g_strcmp0(signal_name, "ReviseJudgement") == 0) { - gboolean approved; - gchar * address; - gchar * path; + gboolean approved = FALSE; + gchar * address = NULL; + gchar * path = NULL; g_variant_get(parameters, "(bso)", &approved, &address, &path); approver_revise_judgement(approver, approved, address, path); g_free(address); -- cgit v1.2.3 From 4145c58e2ee3191f2557f1e558adda0d1f387223 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 22:12:26 -0600 Subject: Making sure to initial string pointers --- src/indicator-application.c | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 577008d..2c4f232 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -802,16 +802,16 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, } if (g_strcmp0(signal_name, "ApplicationAdded") == 0) { - gchar * iconname; + gchar * iconname = NULL; gint position; - gchar * dbusaddress; - gchar * dbusobject; - gchar * icon_theme_path; - gchar * label; - gchar * guide; - gchar * accessible_desc; - gchar * hint; - gchar * title; + gchar * dbusaddress = NULL; + gchar * dbusobject = NULL; + gchar * icon_theme_path = NULL; + gchar * label = NULL; + gchar * guide = NULL; + gchar * accessible_desc = NULL; + gchar * hint = NULL; + gchar * title = NULL; g_variant_get (parameters, "(sisossssss)", &iconname, &position, &dbusaddress, &dbusobject, &icon_theme_path, &label, &guide, @@ -836,8 +836,8 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, } else if (g_strcmp0(signal_name, "ApplicationIconChanged") == 0) { gint position; - gchar * iconname; - gchar * icondesc; + gchar * iconname = NULL; + gchar * icondesc = NULL; g_variant_get (parameters, "(iss)", &position, &iconname, &icondesc); application_icon_changed(self, position, iconname, icondesc); g_free(iconname); @@ -845,15 +845,15 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, } else if (g_strcmp0(signal_name, "ApplicationIconThemePathChanged") == 0) { gint position; - gchar * icon_theme_path; + gchar * icon_theme_path = NULL; g_variant_get (parameters, "(is)", &position, &icon_theme_path); application_icon_theme_path_changed(self, position, icon_theme_path); g_free(icon_theme_path); } else if (g_strcmp0(signal_name, "ApplicationLabelChanged") == 0) { gint position; - gchar * label; - gchar * guide; + gchar * label = NULL; + gchar * guide = NULL; g_variant_get (parameters, "(iss)", &position, &label, &guide); application_label_changed(self, position, label, guide); g_free(label); @@ -915,16 +915,16 @@ get_applications (GObject * obj, GAsyncResult * res, gpointer user_data) static void get_applications_helper (IndicatorApplication * self, GVariant * variant) { - gchar * icon_name; + gchar * icon_name = NULL; gint position; - gchar * dbus_address; - gchar * dbus_object; - gchar * icon_theme_path; - gchar * label; - gchar * guide; - gchar * accessible_desc; - gchar * hint; - gchar * title; + gchar * dbus_address = NULL; + gchar * dbus_object = NULL; + gchar * icon_theme_path = NULL; + gchar * label = NULL; + gchar * guide = NULL; + gchar * accessible_desc = NULL; + gchar * hint = NULL; + gchar * title = NULL; g_variant_get(variant, "(sisossssss)", &icon_name, &position, &dbus_address, &dbus_object, &icon_theme_path, &label, &guide, &accessible_desc, &hint, &title); -- cgit v1.2.3 From a85b08ad050bf8e1acd39f58c5d3984eefd57e6a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 22:13:38 -0600 Subject: Oops, forgot one --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index c0ec327..da5b859 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1099,7 +1099,7 @@ name_changed (GDBusConnection * connection, const gchar * sender_name, { Application * app = (Application *)user_data; - gchar * new_name; + gchar * new_name = NULL; g_variant_get(parameters, "(sss)", NULL, NULL, &new_name); if (new_name == NULL || new_name[0] == 0) -- cgit v1.2.3