Skip to content

Commit fbbaa8a

Browse files
committed
Same handling for non-standard grub paths
1 parent d521fc1 commit fbbaa8a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

rEFIt_UEFI/entry_scan/loader.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ VOID ScanLoader(VOID)
12951295
continue;
12961296
}
12971297
XStringW File = SWPrintf("EFI\\%ls\\grubx64.efi", DirEntry->FileName);
1298-
XStringW OSName = SPrintf("%ls", DirEntry->FileName); // this is folder name, for example "ubuntu"
1298+
XStringW OSName = XStringW().takeValueFrom(DirEntry->FileName); // this is folder name, for example "ubuntu"
12991299
OSName.lowerAscii(); // lowercase for icon name and title (first letter in title will be capitalized later)
13001300
if (FileExists(Volume->RootDir, File)) {
13011301
// check if nonstandard icon mapping is needed
@@ -1309,24 +1309,27 @@ VOID ScanLoader(VOID)
13091309
XStringW LoaderTitle = OSName.subString(0,1); // capitalize first letter for title
13101310
LoaderTitle.upperAscii();
13111311
LoaderTitle += OSName.subString(1, OSName.length()) + L" Linux"_XSW;
1312-
XImage ImageX; //will the image be destroyed or rewritten by next image after the cycle end?
13131312
// Very few linux icons exist in IconNames, but these few may be preloaded, so check that first
1314-
ImageX = ThemeX.GetIcon(L"os_"_XSW + OSName);
1313+
XImage ImageX = ThemeX.GetIcon(L"os_"_XSW + OSName); //will the image be destroyed or rewritten by next image after the cycle end?
13151314
if (ImageX.isEmpty()) {
13161315
// no preloaded icon, try to load from dir
1317-
ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + OSName).wc_str());
1316+
ImageX.LoadXImage(ThemeX.ThemeDir, L"os_"_XSW + OSName);
13181317
}
13191318
AddLoaderEntry(File, NullXStringArray, LoaderTitle, Volume,
13201319
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
13211320
} //anyway continue search other entries
13221321
}
13231322
DirIterClose(&DirIter);
13241323

1324+
// check for non-standard grub path
13251325
for (Index = 0; Index < LinuxEntryDataCount; ++Index) {
13261326
if (FileExists(Volume->RootDir, LinuxEntryData[Index].Path)) {
1327-
XImage ImageX;
1328-
XStringW IconXSW = XStringW().takeValueFrom(LinuxEntryData[Index].Icon);
1329-
ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + IconXSW.subString(0, IconXSW.indexOf(','))).wc_str());
1327+
XStringW OSIconName = XStringW().takeValueFrom(LinuxEntryData[Index].Icon);
1328+
OSIconName = OSIconName.subString(0, OSIconName.indexOf(','));
1329+
XImage ImageX = ThemeX.GetIcon(L"os_"_XSW + OSIconName);
1330+
if (ImageX.isEmpty()) {
1331+
ImageX.LoadXImage(ThemeX.ThemeDir, L"os_"_XSW + OSIconName);
1332+
}
13301333
AddLoaderEntry(LinuxEntryData[Index].Path, NullXStringArray, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
13311334
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
13321335
}

0 commit comments

Comments
 (0)