Blame SOURCES/0001-crash-with-broken-theme.patch

2bcc91
From 3a644c151f27f439c36170f0958fd21cf1cc54d0 Mon Sep 17 00:00:00 2001
2bcc91
From: Milan Crha <mcrha@redhat.com>
2bcc91
Date: Thu, 3 Jun 2021 08:33:53 +0200
2bcc91
Subject: [PATCH] gs-feature-tile: Do not abort when the theme is broken
2bcc91
2bcc91
Just print a warning when the theme doesn't provide 'theme_fg_color' and
2bcc91
fallback to black color.
2bcc91
2bcc91
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1228
2bcc91
---
2bcc91
 src/gs-feature-tile.c | 14 +++++++++++---
2bcc91
 1 file changed, 11 insertions(+), 3 deletions(-)
2bcc91
2bcc91
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
2bcc91
index 1c85083eb..158af1e56 100644
2bcc91
--- a/src/gs-feature-tile.c
2bcc91
+++ b/src/gs-feature-tile.c
2bcc91
@@ -268,7 +268,6 @@ gs_feature_tile_refresh (GsAppTile *self)
2bcc91
 		if (key_colors != tile->key_colors_cache) {
2bcc91
 			g_autoptr(GArray) colors = NULL;
2bcc91
 			GdkRGBA fg_rgba;
2bcc91
-			gboolean fg_rgba_valid;
2bcc91
 			GsHSBC fg_hsbc;
2bcc91
 
2bcc91
 			/* Look up the foreground colour for the feature tile,
2bcc91
@@ -283,8 +282,17 @@ gs_feature_tile_refresh (GsAppTile *self)
2bcc91
 			 * @min_abs_contrast contrast with the foreground, so
2bcc91
 			 * that the text is legible.
2bcc91
 			 */
2bcc91
-			fg_rgba_valid = gtk_style_context_lookup_color (context, "theme_fg_color", &fg_rgba);
2bcc91
-			g_assert (fg_rgba_valid);
2bcc91
+			if (!gtk_style_context_lookup_color (context, "theme_fg_color", &fg_rgba)) {
2bcc91
+				static gboolean i_know = FALSE;
2bcc91
+				if (!i_know) {
2bcc91
+					i_know = TRUE;
2bcc91
+					g_warning ("The theme doesn't provide 'theme_fg_color', fallbacking to black");
2bcc91
+				}
2bcc91
+				fg_rgba.red = 0.0;
2bcc91
+				fg_rgba.green = 0.0;
2bcc91
+				fg_rgba.blue = 0.0;
2bcc91
+				fg_rgba.alpha = 1.0;
2bcc91
+			}
2bcc91
 
2bcc91
 			gtk_rgb_to_hsv (fg_rgba.red, fg_rgba.green, fg_rgba.blue,
2bcc91
 					&fg_hsbc.hue, &fg_hsbc.saturation, &fg_hsbc.brightness);
2bcc91
-- 
2bcc91
GitLab
2bcc91