From 9cb47b71cb089486cd9f6156f53f3bf1741809a0 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 5 Mar 2021 11:57:53 +0100 Subject: [PATCH 1/2] two-step: Always load the BGRT fallback image view_set_bgrt_background() can fail even if the BGRT image was loaded successfully. So we may need the fallback image even though the BGRT image was loaded successfully. This commit also fixes plugin->background_bgrt_fallback_image not being free-ed and set to NULL when loading the fallback image fails. Note this also drops the clearing of the use_firmware_background flagss when we fail to load both the BGRT and the fallback images. Clearing these flags is not necessary. They are only checked if plugin->background_bgrt_image or plugin->background_bgrt_fallback_image are non NULL; and if the loading of both images failed then both are NULL. Signed-off-by: Hans de Goede --- src/plugins/splash/two-step/plugin.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c index eade1ac..7dcd66e 100644 --- a/src/plugins/splash/two-step/plugin.c +++ b/src/plugins/splash/two-step/plugin.c @@ -1693,16 +1693,16 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin, plugin->background_bgrt_raw_width = ply_image_get_width (plugin->background_bgrt_image); plugin->background_bgrt_raw_height = ply_image_get_height (plugin->background_bgrt_image); } else { - ply_trace ("loading background bgrt fallback image"); - ply_image_free (plugin->background_bgrt_image); plugin->background_bgrt_image = NULL; + } + } - if (!ply_image_load (plugin->background_bgrt_fallback_image)) { - for (i = 0; i < PLY_BOOT_SPLASH_MODE_COUNT; i++) - plugin->mode_settings[i].use_firmware_background = false; - plugin->use_firmware_background = false; - } + if (plugin->background_bgrt_fallback_image != NULL) { + ply_trace ("loading background bgrt fallback image"); + if (!ply_image_load (plugin->background_bgrt_fallback_image)) { + ply_image_free (plugin->background_bgrt_fallback_image); + plugin->background_bgrt_fallback_image = NULL; } } From c5db6cf2d1473c2f63e1a34f22c0832ab78c55ef Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 5 Mar 2021 12:02:21 +0100 Subject: [PATCH 2/2] two-step: Only create background_bgrt_fallback_image if use_firmware_background is set We should not create (and try to use) the background_bgrt_fallback_image when the config file has not requested use of the firmware-background. Otherwise we will end up using bgrt-fallback.png if present even when the config file has not requested usage of the firmware-background. Signed-off-by: Hans de Goede --- src/plugins/splash/two-step/plugin.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c index 7dcd66e..ed83d8b 100644 --- a/src/plugins/splash/two-step/plugin.c +++ b/src/plugins/splash/two-step/plugin.c @@ -1076,10 +1076,6 @@ create_plugin (ply_key_file_t *key_file) plugin->background_tile_image = ply_image_new (image_path); free (image_path); - asprintf (&image_path, "%s/bgrt-fallback.png", image_dir); - plugin->background_bgrt_fallback_image = ply_image_new (image_path); - free (image_path); - asprintf (&image_path, "%s/watermark.png", image_dir); plugin->watermark_image = ply_image_new (image_path); free (image_path); @@ -1182,9 +1178,14 @@ create_plugin (ply_key_file_t *key_file) load_mode_settings (plugin, key_file, "system-upgrade", PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE); load_mode_settings (plugin, key_file, "firmware-upgrade", PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE); - if (plugin->use_firmware_background) + if (plugin->use_firmware_background) { plugin->background_bgrt_image = ply_image_new ("/sys/firmware/acpi/bgrt/image"); + asprintf (&image_path, "%s/bgrt-fallback.png", image_dir); + plugin->background_bgrt_fallback_image = ply_image_new (image_path); + free (image_path); + } + plugin->dialog_clears_firmware_background = ply_key_file_get_bool (key_file, "two-step", "DialogClearsFirmwareBackground");