[gnome-software: 5/7] gs-details-page: Explicitly handle empty version history array
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 5/7] gs-details-page: Explicitly handle empty version history array
- Date: Fri, 30 Apr 2021 12:08:49 +0000 (UTC)
commit bd7505262376b1b15ad245e9eb34231fe39c5107
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Apr 29 15:50:36 2021 +0100
gs-details-page: Explicitly handle empty version history array
This makes the code a bit more robust.
It’s not actually needed, as the current behaviour of
gs_app_get_version_history() is to either return `NULL` or a non-empty
array — never an empty array. However, guaranteeing that behaviour would
defy precedent in other APIs, and be confusing to document, so just
handle the case of empty arrays in the callers anyway, to make their
expected behaviour clear.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
src/gs-app-version-history-dialog.c | 2 +-
src/gs-details-page.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-app-version-history-dialog.c b/src/gs-app-version-history-dialog.c
index 94d55cc0c..5262596a2 100644
--- a/src/gs-app-version-history-dialog.c
+++ b/src/gs-app-version-history-dialog.c
@@ -34,7 +34,7 @@ populate_version_history (GsAppVersionHistoryDialog *dialog,
gs_container_remove_all (GTK_CONTAINER (dialog->listbox));
version_history = gs_app_get_version_history (app);
- if (version_history == NULL) {
+ if (version_history == NULL || version_history->len == 0) {
GtkWidget *row;
row = gs_app_version_history_row_new ();
gs_app_version_history_row_set_info (GS_APP_VERSION_HISTORY_ROW (row),
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 2c954b0b9..6f8520f76 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1347,7 +1347,7 @@ gs_details_page_refresh_all (GsDetailsPage *self)
/* set version history */
version_history = gs_app_get_version_history (self->app);
- if (version_history == NULL) {
+ if (version_history == NULL || version_history->len == 0) {
const char *version = gs_app_get_version (self->app);
if (version == NULL || *version == '\0')
gtk_widget_set_visible (self->list_box_version_history, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]