From 1f85d633c4a6be98b8699dc70f20016a972268d2 Mon Sep 17 00:00:00 2001 From: asava Date: Tue, 14 Apr 2020 23:33:36 +0300 Subject: [PATCH] Correct refactoring of CustomBoot --- rEFIt_UEFI/Platform/Settings.cpp | 27 +++++++++++++-------------- rEFIt_UEFI/entry_scan/bootscreen.cpp | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 53a24445a..ad23dc04a 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -1907,13 +1907,13 @@ FillinCustomEntry ( } else if (AsciiStriCmp (Prop->string, "Theme") == 0) { Entry->CustomBoot = CUSTOM_BOOT_THEME; } else { - // CHAR16 *customLogo = PoolPrint(L"%a", Prop->string); + // CHAR16 *customLogo = PoolPrint(L"%a", Prop->string); XStringW customLogo = XStringW().takeValueFrom(Prop->string); Entry->CustomBoot = CUSTOM_BOOT_USER; Entry->CustomLogo.LoadXImage(SelfRootDir, customLogo); if (Entry->CustomLogo.isEmpty()) { DBG ("Custom boot logo not found at path `%ls`!\n", customLogo.wc_str()); - Entry->CustomBoot = CUSTOM_BOOT_USER_DISABLED; + Entry->CustomBoot = CUSTOM_BOOT_DISABLED; } } } else if ((Prop->type == kTagTypeData) && @@ -1922,12 +1922,14 @@ FillinCustomEntry ( Entry->CustomLogo.FromPNG(Prop->data, Prop->dataLen); if (Entry->CustomLogo.isEmpty()) { DBG ("Custom boot logo not decoded from data!\n"/*, Prop->string*/); - Entry->CustomBoot = CUSTOM_BOOT_USER_DISABLED; + Entry->CustomBoot = CUSTOM_BOOT_DISABLED; } } else { Entry->CustomBoot = CUSTOM_BOOT_USER_DISABLED; } - DBG ("Custom entry boot %s LogoWidth = (0x%lld)\n", CustomBootModeToStr(Entry->CustomBoot), Entry->CustomLogo.GetWidth()); + DBG ("Custom entry boot %s LogoWidth = (0x%lld)\n", CustomBootModeToStr(Entry->CustomBoot), Entry->CustomLogo.GetWidth()); + } else { + Entry->CustomBoot = CUSTOM_BOOT_DISABLED; } Prop = GetProperty(DictPointer, "BootBgColor"); @@ -2626,19 +2628,17 @@ GetEarlyUserSettings ( } else if (AsciiStriCmp (Prop->string, "Theme") == 0) { gSettings.CustomBoot = CUSTOM_BOOT_THEME; } else { - CHAR16 *customLogo = PoolPrint (L"%a", Prop->string); + // CHAR16 *customLogo = PoolPrint (L"%a", Prop->string); + XStringW customLogo = XStringW().takeValueFrom(Prop->string); gSettings.CustomBoot = CUSTOM_BOOT_USER; if (gSettings.CustomLogo != NULL) { delete gSettings.CustomLogo; } gSettings.CustomLogo = new XImage; gSettings.CustomLogo->LoadXImage(RootDir, customLogo); - if (gSettings.CustomLogo == NULL) { - DBG ("Custom boot logo not found at path `%ls`!\n", customLogo); - } - - if (customLogo != NULL) { - FreePool (customLogo); + if (gSettings.CustomLogo->isEmpty()) { + DBG ("Custom boot logo not found at path `%ls`!\n", customLogo.wc_str()); + gSettings.CustomBoot = CUSTOM_BOOT_DISABLED; } } } else if ((Prop->type == kTagTypeData) && @@ -2651,7 +2651,7 @@ GetEarlyUserSettings ( gSettings.CustomLogo->FromPNG(Prop->data, Prop->dataLen); if (gSettings.CustomLogo->isEmpty()) { DBG ("Custom boot logo not decoded from data!\n"/*, Prop->string*/); - gSettings.CustomBoot = CUSTOM_BOOT_DISABLED; + gSettings.CustomBoot = CUSTOM_BOOT_DISABLED; } } else { gSettings.CustomBoot = CUSTOM_BOOT_USER_DISABLED; @@ -2659,8 +2659,7 @@ GetEarlyUserSettings ( } else { gSettings.CustomBoot = CUSTOM_BOOT_DISABLED; } - - DBG ("Custom boot %s (0x%llX)\n", CustomBootModeToStr(gSettings.CustomBoot), (uintptr_t)gSettings.CustomLogo); + DBG ("Custom boot %s (0x%llX)\n", CustomBootModeToStr(gSettings.CustomBoot), (uintptr_t)gSettings.CustomLogo); } //*** SYSTEM *** diff --git a/rEFIt_UEFI/entry_scan/bootscreen.cpp b/rEFIt_UEFI/entry_scan/bootscreen.cpp index b0afc1de7..273e6bf3b 100644 --- a/rEFIt_UEFI/entry_scan/bootscreen.cpp +++ b/rEFIt_UEFI/entry_scan/bootscreen.cpp @@ -718,7 +718,7 @@ STATIC UINT8 whiteAppleLogo[] = { static CONST CHAR8 *CustomBootModeStr[] = { "CUSTOM_BOOT_DISABLED", - "CUSTOM_BOOT_DISABLED", + "CUSTOM_BOOT_USER_DISABLED", "CUSTOM_BOOT_NONE", "CUSTOM_BOOT_APPLE", "CUSTOM_BOOT_ALT_APPLE",