Correct some problems when changing config files

This commit is contained in:
asava 2020-05-01 03:14:11 +03:00
parent 5ad1616d7f
commit 64de6d0fef
3 changed files with 33 additions and 14 deletions

View File

@ -65,7 +65,7 @@ INTN LayoutBannerOffset = 64;
INTN LayoutTextOffset = 0;
INTN LayoutButtonOffset = 0;
ACPI_PATCHED_AML *ACPIPatchedAML;
ACPI_PATCHED_AML *ACPIPatchedAML = NULL;
SIDELOAD_KEXT *InjectKextList = NULL;
//SYSVARIABLES *SysVariables;
CHAR16 *IconFormat = NULL;
@ -96,7 +96,7 @@ UINTN ThemesNum = 0;
CONST CHAR16 *ThemesList[100]; //no more then 100 themes?
UINTN ConfigsNum;
CHAR16 *ConfigsList[20];
UINTN DsdtsNum;
UINTN DsdtsNum = 0;
CHAR16 *DsdtsList[20];
UINTN AudioNum;
HDA_OUTPUTS AudioList[20];
@ -3262,6 +3262,13 @@ GetListOfDsdts ()
INTN NameLen;
CHAR16* AcpiPath = PoolPrint(L"%s\\ACPI\\patched", OEMPath);
if (DsdtsNum > 0) {
for (UINTN i = 0; i < DsdtsNum; i++) {
if (DsdtsList[DsdtsNum] != NULL) {
FreePool(DsdtsList[DsdtsNum]);
}
}
}
DsdtsNum = 0;
OldChosenDsdt = 0xFFFF;
@ -3273,13 +3280,13 @@ GetListOfDsdts ()
continue;
}
snwprintf(FullName, 512, "%ls\\%ls", AcpiPath, DirEntry->FileName);
snwprintf(FullName, 512, "%ls\\%ls", AcpiPath, DirEntry->FileName);
if (FileExists(SelfRootDir, FullName)) {
if (StriCmp(DirEntry->FileName, gSettings.DsdtName) == 0) {
OldChosenDsdt = DsdtsNum;
}
NameLen = StrLen(DirEntry->FileName); //with ".aml"
DsdtsList[DsdtsNum] = (CHAR16*)AllocateCopyPool(NameLen * sizeof(CHAR16) + 2, DirEntry->FileName);
DsdtsList[DsdtsNum] = (CHAR16*)AllocateCopyPool(NameLen * sizeof(CHAR16) + 2, DirEntry->FileName); // if changing, notice freepool above
DsdtsList[DsdtsNum++][NameLen] = L'\0';
DBG("- %ls\n", DirEntry->FileName);
}
@ -3297,6 +3304,14 @@ GetListOfACPI ()
INTN i, Count = gSettings.DisabledAMLCount;
CHAR16* AcpiPath = PoolPrint(L"%s\\ACPI\\patched", OEMPath);
while (ACPIPatchedAML != NULL) {
if (ACPIPatchedAML->FileName) {
FreePool(ACPIPatchedAML->FileName);
}
ACPIPatchedAMLTmp = ACPIPatchedAML;
ACPIPatchedAML = ACPIPatchedAML->Next;
FreePool(ACPIPatchedAMLTmp);
}
ACPIPatchedAML = NULL;
DirIterOpen(SelfRootDir, AcpiPath, &DirIter);
@ -3310,11 +3325,11 @@ GetListOfACPI ()
continue;
}
snwprintf(FullName, 512, "%ls\\%ls", AcpiPath, DirEntry->FileName);
snwprintf(FullName, 512, "%ls\\%ls", AcpiPath, DirEntry->FileName);
if (FileExists(SelfRootDir, FullName)) {
BOOLEAN ACPIDisabled = FALSE;
ACPIPatchedAMLTmp = (__typeof__(ACPIPatchedAMLTmp))AllocateZeroPool(sizeof(ACPI_PATCHED_AML));
ACPIPatchedAMLTmp->FileName = PoolPrint(L"%s", DirEntry->FileName);
ACPIPatchedAMLTmp = (__typeof__(ACPIPatchedAMLTmp))AllocateZeroPool(sizeof(ACPI_PATCHED_AML)); // if changing, notice freepool above
ACPIPatchedAMLTmp->FileName = PoolPrint(L"%s", DirEntry->FileName); // if changing, notice freepool above
for (i = 0; i < Count; i++) {
if ((gSettings.DisabledAML[i] != NULL) &&

View File

@ -2364,12 +2364,17 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
GetListOfDsdts(); //only after GetUserSettings
GetListOfACPI(); //ssdt and other tables
AfterTool = FALSE;
gGuiIsReady = TRUE;
gBootChanged = TRUE;
gThemeChanged = TRUE;
do {
if (gBootChanged && gThemeChanged) { // config changed
GetListOfDsdts(); //only after GetUserSettings
GetListOfACPI(); //ssdt and other tables
}
gBootChanged = FALSE;
MainMenu.Entries.Empty();
OptionMenu.Entries.Empty();
InitKextList();
@ -2415,7 +2420,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if (gThemeNeedInit) {
InitTheme(TRUE, &Now);
gThemeNeedInit = FALSE;
gThemeChanged = TRUE;
} else if (gThemeChanged) {
DBG("change theme\n");
InitTheme(FALSE, NULL);

View File

@ -1020,12 +1020,12 @@ VOID ApplyInputs(VOID)
if (InputItems[i].Valid) {
Status = LoadUserSettings(SelfRootDir, ConfigsList[OldChosenConfig], &dict);
if (!EFI_ERROR(Status)) {
gBootChanged = TRUE;
gThemeChanged = TRUE;
Status = GetUserSettings(SelfRootDir, dict);
if (gConfigDict[2]) FreeTag(gConfigDict[2]);
gConfigDict[2] = dict;
snwprintf(gSettings.ConfigName, 64, "%ls", ConfigsList[OldChosenConfig]);
gBootChanged = TRUE;
gThemeChanged = TRUE;
snwprintf(gSettings.ConfigName, 64, "%ls", ConfigsList[OldChosenConfig]);
}
FillInputs(FALSE);
NeedSave = FALSE;