[gnome-boxes] wizard: Check for null results in media lists
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] wizard: Check for null results in media lists
- Date: Tue, 5 Nov 2019 09:59:54 +0000 (UTC)
commit 61c9ae768a838fa24c9a2583691c57f1ed493c5d
Author: Diego Escalante Urrelo <diegoe gnome org>
Date: Mon Nov 4 14:21:46 2019 -0500
wizard: Check for null results in media lists
Make sure that media results are not null before trying to use them as
GObjects. This prevents a bunch of crashes related to the wizard and
application startup.
See: https://gitlab.com/libosinfo/libosinfo/merge_requests/23
Fixes: https://gitlab.gnome.org/GNOME/gnome-boxes/issues/433
src/search.vala | 6 ++++--
src/wizard-downloads-page.vala | 4 +++-
src/wizard-source.vala | 4 +++-
3 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/search.vala b/src/search.vala
index 09ef2889..46970fbc 100644
--- a/src/search.vala
+++ b/src/search.vala
@@ -50,14 +50,16 @@
private async void load_custom_downloads () {
foreach (var media in yield get_recommended_downloads ()) {
- if (media.url == null)
+ if (media != null && media.url == null)
media_list.append (media);
}
}
public void show_all () {
foreach (var media in media_list) {
- model.append (media);
+ if (media != null) {
+ model.append (media);
+ }
}
}
}
diff --git a/src/wizard-downloads-page.vala b/src/wizard-downloads-page.vala
index 0b77a9cb..e001381f 100644
--- a/src/wizard-downloads-page.vala
+++ b/src/wizard-downloads-page.vala
@@ -69,7 +69,9 @@ private void set_visible_view () {
private async void populate_recommended_list () {
foreach (var media in yield get_recommended_downloads ()) {
- recommended_model.append (media);
+ if (media != null) {
+ recommended_model.append (media);
+ }
}
}
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index a470d1f3..d008692f 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -394,7 +394,9 @@ public void setup_ui (AppWindow window) {
private async void populate_recommended_downloads () {
foreach (var media in yield get_recommended_downloads ()) {
- downloads_model.append (media);
+ if (media != null) {
+ downloads_model.append (media);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]