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 LayoutTextOffset = 0;
INTN LayoutButtonOffset = 0; INTN LayoutButtonOffset = 0;
ACPI_PATCHED_AML *ACPIPatchedAML; ACPI_PATCHED_AML *ACPIPatchedAML = NULL;
SIDELOAD_KEXT *InjectKextList = NULL; SIDELOAD_KEXT *InjectKextList = NULL;
//SYSVARIABLES *SysVariables; //SYSVARIABLES *SysVariables;
CHAR16 *IconFormat = NULL; CHAR16 *IconFormat = NULL;
@ -96,7 +96,7 @@ UINTN ThemesNum = 0;
CONST CHAR16 *ThemesList[100]; //no more then 100 themes? CONST CHAR16 *ThemesList[100]; //no more then 100 themes?
UINTN ConfigsNum; UINTN ConfigsNum;
CHAR16 *ConfigsList[20]; CHAR16 *ConfigsList[20];
UINTN DsdtsNum; UINTN DsdtsNum = 0;
CHAR16 *DsdtsList[20]; CHAR16 *DsdtsList[20];
UINTN AudioNum; UINTN AudioNum;
HDA_OUTPUTS AudioList[20]; HDA_OUTPUTS AudioList[20];
@ -3262,6 +3262,13 @@ GetListOfDsdts ()
INTN NameLen; INTN NameLen;
CHAR16* AcpiPath = PoolPrint(L"%s\\ACPI\\patched", OEMPath); 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; DsdtsNum = 0;
OldChosenDsdt = 0xFFFF; OldChosenDsdt = 0xFFFF;
@ -3273,13 +3280,13 @@ GetListOfDsdts ()
continue; continue;
} }
snwprintf(FullName, 512, "%ls\\%ls", AcpiPath, DirEntry->FileName); snwprintf(FullName, 512, "%ls\\%ls", AcpiPath, DirEntry->FileName);
if (FileExists(SelfRootDir, FullName)) { if (FileExists(SelfRootDir, FullName)) {
if (StriCmp(DirEntry->FileName, gSettings.DsdtName) == 0) { if (StriCmp(DirEntry->FileName, gSettings.DsdtName) == 0) {
OldChosenDsdt = DsdtsNum; OldChosenDsdt = DsdtsNum;
} }
NameLen = StrLen(DirEntry->FileName); //with ".aml" 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'; DsdtsList[DsdtsNum++][NameLen] = L'\0';
DBG("- %ls\n", DirEntry->FileName); DBG("- %ls\n", DirEntry->FileName);
} }
@ -3297,6 +3304,14 @@ GetListOfACPI ()
INTN i, Count = gSettings.DisabledAMLCount; INTN i, Count = gSettings.DisabledAMLCount;
CHAR16* AcpiPath = PoolPrint(L"%s\\ACPI\\patched", OEMPath); 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; ACPIPatchedAML = NULL;
DirIterOpen(SelfRootDir, AcpiPath, &DirIter); DirIterOpen(SelfRootDir, AcpiPath, &DirIter);
@ -3310,11 +3325,11 @@ GetListOfACPI ()
continue; continue;
} }
snwprintf(FullName, 512, "%ls\\%ls", AcpiPath, DirEntry->FileName); snwprintf(FullName, 512, "%ls\\%ls", AcpiPath, DirEntry->FileName);
if (FileExists(SelfRootDir, FullName)) { if (FileExists(SelfRootDir, FullName)) {
BOOLEAN ACPIDisabled = FALSE; BOOLEAN ACPIDisabled = FALSE;
ACPIPatchedAMLTmp = (__typeof__(ACPIPatchedAMLTmp))AllocateZeroPool(sizeof(ACPI_PATCHED_AML)); ACPIPatchedAMLTmp = (__typeof__(ACPIPatchedAMLTmp))AllocateZeroPool(sizeof(ACPI_PATCHED_AML)); // if changing, notice freepool above
ACPIPatchedAMLTmp->FileName = PoolPrint(L"%s", DirEntry->FileName); ACPIPatchedAMLTmp->FileName = PoolPrint(L"%s", DirEntry->FileName); // if changing, notice freepool above
for (i = 0; i < Count; i++) { for (i = 0; i < Count; i++) {
if ((gSettings.DisabledAML[i] != NULL) && 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; AfterTool = FALSE;
gGuiIsReady = TRUE; gGuiIsReady = TRUE;
gBootChanged = TRUE;
gThemeChanged = TRUE;
do { do {
if (gBootChanged && gThemeChanged) { // config changed
GetListOfDsdts(); //only after GetUserSettings
GetListOfACPI(); //ssdt and other tables
}
gBootChanged = FALSE;
MainMenu.Entries.Empty(); MainMenu.Entries.Empty();
OptionMenu.Entries.Empty(); OptionMenu.Entries.Empty();
InitKextList(); InitKextList();
@ -2415,7 +2420,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if (gThemeNeedInit) { if (gThemeNeedInit) {
InitTheme(TRUE, &Now); InitTheme(TRUE, &Now);
gThemeNeedInit = FALSE; gThemeNeedInit = FALSE;
gThemeChanged = TRUE;
} else if (gThemeChanged) { } else if (gThemeChanged) {
DBG("change theme\n"); DBG("change theme\n");
InitTheme(FALSE, NULL); InitTheme(FALSE, NULL);

View File

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