gnome-software/0001-crash-with-broken-them...

39 lines
1.5 KiB
Diff

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
diff -up gnome-software-42.rc/src/gs-feature-tile.c.1 gnome-software-42.rc/src/gs-feature-tile.c
--- gnome-software-42.rc/src/gs-feature-tile.c.1 2022-03-04 16:23:58.566735700 +0100
+++ gnome-software-42.rc/src/gs-feature-tile.c 2022-03-07 08:06:29.046595524 +0100
@@ -411,7 +411,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;
const GsHSBC *chosen_hsbc;
GsHSBC chosen_hsbc_modified;
@@ -429,8 +428,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);