[gnome-software/1876-gnome-software-missing-an-install-upgrade-button-when-opening-an-rpm-file] gs-app: Avoid runtime warning when converting GsApp into string
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1876-gnome-software-missing-an-install-upgrade-button-when-opening-an-rpm-file] gs-app: Avoid runtime warning when converting GsApp into string
- Date: Thu, 25 Aug 2022 10:44:54 +0000 (UTC)
commit 938b44327acb5002cb94ab2e4f731dfa321740d3
Author: Milan Crha <mcrha redhat com>
Date: Thu Aug 25 12:29:08 2022 +0200
gs-app: Avoid runtime warning when converting GsApp into string
For example PackageKit can create apps without id, which can cause a runtime
warning about NULL being used as a value for a key. It can be shown when opening
an .rpm file in the details page.
lib/gs-app.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 3e239dfc2..d157ffb71 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -727,11 +727,18 @@ gs_app_to_string_append (GsApp *app, GString *str)
const gchar *id = gs_app_get_unique_id (app_tmp);
if (id == NULL)
id = gs_app_get_source_default (app_tmp);
- gs_app_kv_lpad (str, "related", id);
+ /* For example PackageKit can create apps without id */
+ if (id != NULL)
+ gs_app_kv_lpad (str, "related", id);
}
for (i = 0; i < gs_app_list_length (priv->history); i++) {
GsApp *app_tmp = gs_app_list_index (priv->history, i);
- gs_app_kv_lpad (str, "history", gs_app_get_unique_id (app_tmp));
+ const gchar *id = gs_app_get_unique_id (app_tmp);
+ if (id == NULL)
+ id = gs_app_get_source_default (app_tmp);
+ /* For example PackageKit can create apps without id */
+ if (id != NULL)
+ gs_app_kv_lpad (str, "history", id);
}
for (i = 0; i < priv->categories->len; i++) {
tmp = g_ptr_array_index (priv->categories, i);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]