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