Revert commit a9cb69 : remove workaround and fix operator = in XIcon.

This commit is contained in:
jief666 2021-05-17 08:52:17 +03:00
parent 1af86d0e9c
commit 82ba60a90a
3 changed files with 12 additions and 18 deletions

View File

@ -99,7 +99,10 @@ ImageNight.FromPNG(ACCESS_EMB_DATA(dark), ACCESS_EMB_SIZE(dark)); \
} }
XIcon::~XIcon() {} XIcon::~XIcon()
{
// memory leak : we can't free (yet?) ImageSVG and ImageSVGnight because operator might have copied it
}
XIcon::XIcon(INTN Index, bool TakeEmbedded) : Id(Index), Name(), Image(), ImageNight(), Native(false), XIcon::XIcon(INTN Index, bool TakeEmbedded) : Id(Index), Name(), Image(), ImageNight(), Native(false),
ImageSVG(nullptr), ImageSVGnight(nullptr), Empty(0) ImageSVG(nullptr), ImageSVGnight(nullptr), Empty(0)
@ -121,16 +124,13 @@ XIcon& XIcon::operator=(const XIcon& src)
{ {
Id = src.Id; Id = src.Id;
Name = src.Name; Name = src.Name;
if (!src.isEmpty()) { Image = src.Image;
Image = src.Image; ImageNight = src.ImageNight;
if (!src.ImageNight.isEmpty()) { Native = src.Native;
ImageNight = src.ImageNight; Empty = src.Empty;
} //this moment we copy pointers. Later it will be class variables
setFilled(); ImageSVG = src.ImageSVG;
//this moment we copy pointers. Later it will be class variables ImageSVGnight = src.ImageSVGnight;
ImageSVG = src.ImageSVG;
ImageSVGnight = src.ImageSVGnight;
}
return *this; return *this;
} }

View File

@ -3179,7 +3179,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
#endif // ENABLE_SECURE_BOOT #endif // ENABLE_SECURE_BOOT
} }
} }
MenuEntryOptions.Image.ImageNight.setEmpty();
MenuEntryOptions.Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_OPTIONS); MenuEntryOptions.Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_OPTIONS);
// DBG("Options: IconID=%lld name=%s empty=%s\n", MenuEntryOptions.Image.Id, MenuEntryOptions.Image.Name.c_str(), // DBG("Options: IconID=%lld name=%s empty=%s\n", MenuEntryOptions.Image.Id, MenuEntryOptions.Image.Name.c_str(),
// MenuEntryOptions.Image.isEmpty()?"пусто":"нет"); // MenuEntryOptions.Image.isEmpty()?"пусто":"нет");
@ -3187,7 +3187,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
MenuEntryOptions.ShortcutLetter = 0x00; MenuEntryOptions.ShortcutLetter = 0x00;
MainMenu.AddMenuEntry(&MenuEntryOptions, false); MainMenu.AddMenuEntry(&MenuEntryOptions, false);
MenuEntryAbout.Image.ImageNight.setEmpty();
MenuEntryAbout.Image = ThemeX.GetIcon((INTN)BUILTIN_ICON_FUNC_ABOUT); MenuEntryAbout.Image = ThemeX.GetIcon((INTN)BUILTIN_ICON_FUNC_ABOUT);
// DBG("About: IconID=%lld name=%s empty=%s\n", MenuEntryAbout.Image.Id, MenuEntryAbout.Image.Name.c_str(), // DBG("About: IconID=%lld name=%s empty=%s\n", MenuEntryAbout.Image.Id, MenuEntryAbout.Image.Name.c_str(),
// MenuEntryAbout.Image.isEmpty()?"пусто":"нет"); // MenuEntryAbout.Image.isEmpty()?"пусто":"нет");
@ -3198,12 +3197,10 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_FUNCS) || MainMenu.Entries.size() == 0) { if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_FUNCS) || MainMenu.Entries.size() == 0) {
if (gSettings.Boot.DisableCloverHotkeys) if (gSettings.Boot.DisableCloverHotkeys)
MenuEntryReset.ShortcutLetter = 0x00; MenuEntryReset.ShortcutLetter = 0x00;
MenuEntryReset.Image.ImageNight.setEmpty();
MenuEntryReset.Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_RESET); MenuEntryReset.Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_RESET);
MainMenu.AddMenuEntry(&MenuEntryReset, false); MainMenu.AddMenuEntry(&MenuEntryReset, false);
if (gSettings.Boot.DisableCloverHotkeys) if (gSettings.Boot.DisableCloverHotkeys)
MenuEntryShutdown.ShortcutLetter = 0x00; MenuEntryShutdown.ShortcutLetter = 0x00;
MenuEntryShutdown.Image.ImageNight.setEmpty();
MenuEntryShutdown.Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_EXIT); MenuEntryShutdown.Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_EXIT);
MainMenu.AddMenuEntry(&MenuEntryShutdown, false); MainMenu.AddMenuEntry(&MenuEntryShutdown, false);
} }

View File

@ -1080,7 +1080,6 @@ void AboutRefit(void)
if (AboutMenu.Entries.size() == 0) { if (AboutMenu.Entries.size() == 0) {
AboutMenu.Daylight = ThemeX.Daylight; AboutMenu.Daylight = ThemeX.Daylight;
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) {
AboutMenu.TitleImage.ImageNight.setEmpty();
AboutMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_ABOUT); AboutMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_ABOUT);
} }
// else { // else {
@ -1139,7 +1138,6 @@ void HelpRefit(void)
if (HelpMenu.Entries.size() == 0) { if (HelpMenu.Entries.size() == 0) {
HelpMenu.Daylight = ThemeX.Daylight; HelpMenu.Daylight = ThemeX.Daylight;
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) {
HelpMenu.TitleImage.ImageNight.setEmpty();
HelpMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_HELP); HelpMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_HELP);
} }
//else { //else {
@ -2604,7 +2602,6 @@ void OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
if (OptionMenu.Entries.size() == 0) { if (OptionMenu.Entries.size() == 0) {
OptionMenu.Daylight = ThemeX.Daylight; OptionMenu.Daylight = ThemeX.Daylight;
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) { if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_MENU_TITLE_IMAGE)) {
OptionMenu.TitleImage.ImageNight.setEmpty();
OptionMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_OPTIONS); OptionMenu.TitleImage = ThemeX.GetIcon(BUILTIN_ICON_FUNC_OPTIONS);
} }
gThemeOptionsChanged = TRUE; gThemeOptionsChanged = TRUE;