Skip to content

Commit 6020c49

Browse files
committed
do not copy xstring8 to xstringw
Signed-off-by: Slice <sergey.slice@gmail.com>
1 parent 459b95b commit 6020c49

4 files changed

Lines changed: 32 additions & 54 deletions

File tree

rEFIt_UEFI/Platform/Settings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class CUSTOM_LOADER_ENTRY_SETTINGS {
275275
XStringW Path = XStringW();
276276
undefinable_XString8 Arguments = undefinable_XString8();
277277
XString8 AddArguments = XString8();
278-
XString8 FullTitle = XStringW();
278+
XString8 FullTitle = XString8();
279279
XStringW Settings = XStringW(); // path of a config.plist that'll be read at
280280
// the beginning of startloader
281281
char32_t Hotkey = 0;
@@ -302,7 +302,7 @@ class CUSTOM_LOADER_ENTRY_SETTINGS {
302302

303303
public: // temporary, must be protected:
304304
XStringW m_DriveImagePath = XStringW();
305-
XString8 m_Title = XStringW();
305+
XString8 m_Title = XString8();
306306
UINT8 CustomLogoTypeSettings = 0;
307307
XStringW m_ImagePath = XStringW();
308308

rEFIt_UEFI/entry_scan/legacy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ void AddCustomLegacy(void)
385385
}
386386
// Create a legacy entry for this volume
387387
DBG("\n");
388-
if (AddLegacyEntry(Custom.settings.FullTitle, Custom.settings.Title, Volume, &MainIcon, &DriveIcon, Custom.settings.Hotkey, true))
388+
if (AddLegacyEntry(XStringW(Custom.settings.FullTitle), Custom.settings.Title, Volume, &MainIcon, &DriveIcon, Custom.settings.Hotkey, true))
389389
{
390390
// DBG("match!\n");
391391
}

rEFIt_UEFI/entry_scan/loader.cpp

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ CONST XStringW GetOSIconName(const MacOsVersion &OSVersion) {
10411041

10421042
STATIC LOADER_ENTRY *CreateLoaderEntry(
10431043
IN CONST XStringW &LoaderPath, IN CONST XString8Array &LoaderOptions,
1044-
IN CONST XString8 &FullTitle, IN CONST XString8 &LoaderTitle,
1044+
IN CONST XStringW &FullTitle, IN CONST XStringW &LoaderTitle,
10451045
IN REFIT_VOLUME *Volume, IN XIcon *Image, IN XIcon *DriveImage,
10461046
IN UINT8 OSType, IN UINT8 Flags, IN wchar_t Hotkey,
10471047
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor, IN UINT8 CustomBoot,
@@ -1099,7 +1099,6 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(
10991099
}
11001100
}
11011101

1102-
XString8 Title;
11031102
// If this isn't a custom entry make sure it's not hidden by a custom entry
11041103
for (size_t CustomIndex = 0;
11051104
CustomIndex < GlobalConfig.CustomEntries.size(); ++CustomIndex) {
@@ -1116,10 +1115,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(
11161115
INTN path_match = 0;
11171116
INTN type_match = 0;
11181117

1119-
if (Custom.settings.FullTitle.notEmpty()) {
1120-
Title = Custom.settings.FullTitle;
1121-
}
1122-
Entry->Title = Custom.settings.FullTitle;
1118+
Entry->Title.SWPrintf("%ls", FullTitle.wc_str());
11231119

11241120
// Check if volume match
11251121
if (Custom.settings.Volume.notEmpty()) {
@@ -1270,14 +1266,12 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(
12701266
OSIconName = LinuxIconNameFromPath(
12711267
LoaderPath, Volume->RootDir); // something named "issue"
12721268
}
1273-
// DBG("linux name icon from path= %ls\n", OSIconName.wc_str());
1274-
// DBG("LoaderTitle=%s Full Title=%s Title=%ls\n", LoaderTitle.c_str(),
1275-
// FullTitle.c_str(), Entry->Title.wc_str());
1276-
if (AsciiStrStr(LoaderTitle.c_str(), "Arch")) {
1269+
1270+
if (StrStr(LoaderTitle.wc_str(), L"Arch")) {
12771271
OSIconName = L"arch"_XSW;
1278-
} else if (AsciiStrStr(LoaderTitle.c_str(), "Ubuntu")) {
1272+
} else if (StrStr(LoaderTitle.wc_str(), L"Ubuntu")) {
12791273
OSIconName = L"ubuntu"_XSW;
1280-
} else if (AsciiStrStr(LoaderTitle.c_str(), "Alt")) {
1274+
} else if (StrStr(LoaderTitle.wc_str(), L"Alt")) {
12811275
OSIconName = L"alt"_XSW;
12821276
}
12831277
DBG("assigned linux name icon %ls\n", OSIconName.wc_str());
@@ -1298,18 +1292,19 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(
12981292
Entry->OSName = OSIconName.subString(0, OSIconName.indexOf(',')); // TODO
12991293
// SmbiosList.AddReference(OSName.forgetDataWithoutFreeing(), true);
13001294

1301-
Entry->Title = FullTitle;
1295+
Entry->Title.SWPrintf("%ls", FullTitle.wc_str());
1296+
13021297
if (Entry->Title.isEmpty() && Volume->VolLabel.notEmpty()) {
13031298
if (Volume->VolLabel[0] == L'#') {
13041299
Entry->Title.SWPrintf("Boot %ls from %ls",
13051300
(!LoaderTitle.isEmpty())
1306-
? XStringW(LoaderTitle).wc_str()
1301+
? LoaderTitle.wc_str()
13071302
: LoaderPath.basename().wc_str(),
13081303
Volume->VolLabel.data(1));
13091304
} else {
13101305
Entry->Title.SWPrintf("Boot %ls from %ls",
13111306
(!LoaderTitle.isEmpty())
1312-
? XStringW(LoaderTitle).wc_str()
1307+
? LoaderTitle.wc_str()
13131308
: LoaderPath.basename().wc_str(),
13141309
Volume->VolLabel.wc_str());
13151310
}
@@ -1323,7 +1318,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(
13231318
// ==%llu\n",Entry->VolName, StrLen(Entry->VolName));
13241319
if (BootCampStyle) {
13251320
if (!LoaderTitle.isEmpty()) {
1326-
Entry->Title = LoaderTitle;
1321+
Entry->Title.SWPrintf("%ls", LoaderTitle.wc_str());
13271322
} else {
13281323
Entry->Title =
13291324
(BasenameXW.contains(L"-"))
@@ -1333,33 +1328,31 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(
13331328
} else {
13341329
Entry->Title.SWPrintf(
13351330
"Boot %ls from %ls",
1336-
(!LoaderTitle.isEmpty()) ? XStringW(LoaderTitle).wc_str()
1331+
(!LoaderTitle.isEmpty()) ? LoaderTitle.wc_str()
13371332
: LoaderPath.basename().wc_str(),
13381333
(BasenameXW.contains(L"-"))
13391334
? (BasenameXW.subString(0, BasenameXW.indexOf(L"-") + 1) + L"..)")
13401335
.wc_str()
13411336
: BasenameXW.wc_str());
13421337
}
13431338
}
1344-
// DBG("check Entry->Title \n");
1339+
13451340
if (Entry->Title.isEmpty()) {
1346-
// DBG("encounter LoaderTitle ==%ls and Entry->VolName ==%ls\n",
1347-
// LoaderTitle.wc_str(), Entry->VolName);
13481341
if (BootCampStyle) {
1349-
if ((StriCmp(XStringW(LoaderTitle).wc_str(), L"macOS") == 0) ||
1350-
(StriCmp(XStringW(LoaderTitle).wc_str(), L"Recovery") == 0)) {
1342+
if ((StriCmp(LoaderTitle.wc_str(), L"macOS") == 0) ||
1343+
(StriCmp(LoaderTitle.wc_str(), L"Recovery") == 0)) {
13511344
Entry->Title.takeValueFrom(Entry->DisplayedVolName);
13521345
} else {
13531346
if (!LoaderTitle.isEmpty()) {
1354-
Entry->Title = LoaderTitle;
1347+
Entry->Title.SWPrintf("%ls", LoaderTitle.wc_str());
13551348
} else {
13561349
Entry->Title = LoaderPath.basename();
13571350
}
13581351
}
13591352
} else {
13601353
Entry->Title.SWPrintf("Boot %ls from %ls",
13611354
(!LoaderTitle.isEmpty())
1362-
? XStringW(LoaderTitle).wc_str()
1355+
? LoaderTitle.wc_str()
13631356
: LoaderPath.basename().wc_str(),
13641357
Entry->DisplayedVolName.wc_str());
13651358
}
@@ -1385,16 +1378,15 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(
13851378
} else {
13861379
Entry->Image = ThemeX->LoadOSIcon(OSIconName);
13871380
}
1388-
// DBG("Load DriveImage\n");
1381+
13891382
// Load DriveImage
13901383
if (DriveImage) {
1391-
// DBG("DriveImage presents\n");
13921384
Entry->DriveImage = *DriveImage;
13931385
} else {
13941386
Entry->DriveImage =
13951387
ScanVolumeDefaultIcon(Volume, Entry->LoaderType, Volume->DevicePath);
13961388
}
1397-
// DBG("HideBadges=%llu Volume=%ls ", ThemeX->HideBadges, Volume->VolName);
1389+
13981390
if (ThemeX->HideBadges & HDBADGES_SHOW) {
13991391
if (ThemeX->HideBadges & HDBADGES_SWAP) {
14001392
Entry->BadgeImage.Image = XImage(Entry->DriveImage.Image, 0);
@@ -1405,14 +1397,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(
14051397
}
14061398
}
14071399
Entry->BootBgColor = BootBgColor;
1408-
// Entry->KernelAndKextPatches =
1409-
// ((Patches == NULL) ? gSettings.KernelAndKextPatches : *Patches);
14101400
Entry->KPDebug = ((Patches == NULL) ? gSettings.KernelAndKextPatches.KPDebug : Patches->KPDebug);
1411-
// if (Patches) {
1412-
// Entry->KernelAndKextPatches.takeValueFrom(*Patches);
1413-
// } else {
1414-
// Entry->KernelAndKextPatches.takeValueFrom(gSettings.KernelAndKextPatches);
1415-
// }
14161401

14171402
#ifdef DUMP_KERNEL_KEXT_PATCHES
14181403
DumpKernelAndKextPatches(gSettings.KernelAndKextPatches);
@@ -1451,7 +1436,7 @@ void LOADER_ENTRY::AddDefaultMenu() {
14511436
DisplayedVolName.wc_str());
14521437

14531438
SubScreen->TitleImage = Image;
1454-
SubScreen->ID = LoaderType + 40; // wow
1439+
SubScreen->ID = LoaderType + 40;
14551440
// DBG("get anime for os=%lld\n", SubScreen->ID);
14561441
SubScreen->GetAnime();
14571442
VolumeSize = RShiftU64(MultU64x32(Volume->BlockIO->Media->LastBlock,
@@ -2548,16 +2533,9 @@ void ScanLoader(void)
25482533

25492534
DBG("Entries list before ordering\n");
25502535
for (size_t idx = 0; idx < MainMenu.Entries.sizeIncludingHidden(); idx++) {
2551-
if (MainMenu.Entries.ElementAt(idx).getLOADER_ENTRY()) {
2552-
DBG(" Entry %zd : %ls%s \n", idx,
2553-
MainMenu.Entries.ElementAt(idx).Title.wc_str(),
2554-
MainMenu.Entries.ElementAt(idx).Hidden ? " (hidden)" : ""
2555-
);
2556-
} else {
2557-
DBG(" Entry %zd : %ls%s\n", idx,
2558-
MainMenu.Entries.ElementAt(idx).Title.wc_str(),
2559-
MainMenu.Entries.ElementAt(idx).Hidden ? " (hidden)" : "");
2560-
}
2536+
DBG(" Entry %zd : %ls %s\n", idx,
2537+
MainMenu.Entries.ElementAt(idx).Title.wc_str(),
2538+
MainMenu.Entries.ElementAt(idx).Hidden ? " (hidden)" : "");
25612539
}
25622540

25632541
// Hide redundant preboot partition
@@ -2755,7 +2733,7 @@ void ScanLoader(void)
27552733

27562734
DBG("Entries list after ordering\n");
27572735
for (size_t idx = 0; idx < MainMenu.Entries.sizeIncludingHidden(); idx++) {
2758-
DBG(" Entry %zd : %ls%s\n", idx,
2736+
DBG(" Entry %zd : %ls %s\n", idx,
27592737
MainMenu.Entries.ElementAt(idx).Title.wc_str(),
27602738
MainMenu.Entries.ElementAt(idx).Hidden ? " (hidden)" : "");
27612739
}
@@ -2815,7 +2793,7 @@ STATIC void AddCustomSubEntry(REFIT_VOLUME *Volume, IN UINTN CustomIndex,
28152793

28162794
// Create an entry for this volume
28172795
Entry = CreateLoaderEntry(
2818-
CustomPath, CustomOptions, Custom.getFullTitle(), Custom.getTitle(),
2796+
CustomPath, CustomOptions, XStringW(Custom.getFullTitle()), XStringW(Custom.getTitle()),
28192797
Volume, NULL, NULL, parentType, newCustomFlags, 0, {0, 0, 0, 0}, 0,
28202798
NullXImage,
28212799
/*(KERNEL_AND_KEXT_PATCHES *)(((UINTN)Custom) +
@@ -3199,8 +3177,8 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex, IN const XStringW &_CustomPath,
31993177
DBG("match!\n");
32003178
// Create an entry for this volume
32013179
Entry = CreateLoaderEntry(
3202-
CustomPath, CustomOptions, Custom.settings.FullTitle,
3203-
Custom.settings.dgetTitle(), Volume,
3180+
CustomPath, CustomOptions, XStringW(Custom.settings.FullTitle),
3181+
XStringW(Custom.settings.dgetTitle()), Volume,
32043182
(Image.isEmpty() ? NULL : &Image),
32053183
(DriveImage.isEmpty() ? NULL : &DriveImage), Custom.settings.Type,
32063184
newCustomFlags, Custom.settings.Hotkey, Custom.settings.BootBgColor,

rEFIt_UEFI/entry_scan/tool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ void AddCustomTool(void)
308308
}
309309
DBG("match!\n");
310310
if (Image.isEmpty()) {
311-
AddToolEntry(Custom.settings.Path, Custom.settings.FullTitle.wc_str(), Custom.settings.Title.wc_str(), Volume, ThemeX->GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom.settings.Hotkey, Custom.getLoadOptions());
311+
AddToolEntry(Custom.settings.Path, XStringW(Custom.settings.FullTitle).wc_str(), Custom.settings.Title.wc_str(), Volume, ThemeX->GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom.settings.Hotkey, Custom.getLoadOptions());
312312
} else {
313313
// Create a legacy entry for this volume
314-
AddToolEntry(Custom.settings.Path, Custom.settings.FullTitle.wc_str(), Custom.settings.Title.wc_str(), Volume, Image, Custom.settings.Hotkey, Custom.getLoadOptions());
314+
AddToolEntry(Custom.settings.Path, XStringW(Custom.settings.FullTitle).wc_str(), Custom.settings.Title.wc_str(), Volume, Image, Custom.settings.Hotkey, Custom.getLoadOptions());
315315
}
316316
// break; // break scan volumes, continue scan entries -- why?
317317
}

0 commit comments

Comments
 (0)