[POWERCFG] Fix minor power scheme issues
authorEric Kohl <eric.kohl@reactos.org>
Sun, 28 Apr 2019 11:18:12 +0000 (13:18 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 28 Apr 2019 11:18:52 +0000 (13:18 +0200)
- Really fix the exception that occurs on closing the property sheet.
- Use the correct scheme ID when the current power scheme is set.

dll/cpl/powercfg/powershemes.c

index 7d1441a..7654f17 100644 (file)
@@ -162,9 +162,12 @@ DestroySchemesList(
     PLIST_ENTRY ListEntry;
     PPOWER_SCHEME pScheme;
 
-    while (!IsListEmpty(&pPageData->PowerSchemesList))
+    for (;;)
     {
         ListEntry = pPageData->PowerSchemesList.Flink;
+        if (ListEntry == &pPageData->PowerSchemesList)
+            break;
+
         pScheme = CONTAINING_RECORD(ListEntry, POWER_SCHEME, ListEntry);
         DeletePowerScheme(pScheme);
     }
@@ -560,7 +563,7 @@ Pos_SaveData(HWND hwndDlg)
         pScheme->PowerPolicy.mach.DozeS4TimeoutDc = Sec[tmp];
     }
 
-    SetActivePwrScheme(iCurSel, NULL, &pScheme->PowerPolicy);
+    SetActivePwrScheme(pScheme->uId, NULL, &pScheme->PowerPolicy);
     LoadConfig(hwndDlg);
 }