From fcedca06d11f59e08072e8784b685360c8fdf71d Mon Sep 17 00:00:00 2001 From: Lesueur Benjamin Date: Fri, 27 Sep 2024 16:13:56 +0200 Subject: [PATCH] Fixed an issue causing a crash on null or empty TDPOverrideValues --- HandheldCompanion/Managers/PerformanceManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/HandheldCompanion/Managers/PerformanceManager.cs b/HandheldCompanion/Managers/PerformanceManager.cs index 35ecca2b0..ac83597fe 100644 --- a/HandheldCompanion/Managers/PerformanceManager.cs +++ b/HandheldCompanion/Managers/PerformanceManager.cs @@ -140,7 +140,7 @@ private static void SettingsManagerOnSettingValueChanged(string name, object val private static void PowerProfileManager_Applied(PowerProfile profile, UpdateSource source) { // apply profile defined TDP - if (profile.TDPOverrideEnabled && profile.TDPOverrideValues is not null) + if (profile.TDPOverrideEnabled) { if (!profile.AutoTDPEnabled) { @@ -152,7 +152,7 @@ private static void PowerProfileManager_Applied(PowerProfile profile, UpdateSour AutoTDPMax = SettingsManager.GetInt("ConfigurableTDPOverrideUp"); } - else + else if (profile.TDPOverrideValues is not null) { // Both manual TDP and AutoTDP are on, // use manual slider as the max limit for AutoTDP @@ -695,6 +695,10 @@ private static void RequestTDP(PowerType type, double value, bool immediate = fa private static async void RequestTDP(double[] values, bool immediate = false) { + // Handle null or empty array scenario + if (values == null || values.Length == 0) + return; + for (int idx = (int)PowerType.Slow; idx <= (int)PowerType.Fast; idx++) { RequestTDP((PowerType)idx, values[idx], immediate);