mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-03-11 23:44:26 +01:00
PowerControl: Improve null handling
This commit is contained in:
parent
a30ef2c400
commit
1ff7bed567
|
|
@ -105,7 +105,7 @@ namespace CommonHelpers
|
|||
}
|
||||
}
|
||||
|
||||
public static T WithGlobalMutex<T>(int timeoutMs, Func<T> func)
|
||||
public static T? WithGlobalMutex<T>(int timeoutMs, Func<T?> func)
|
||||
{
|
||||
var mutex = WaitGlobalMutex(timeoutMs);
|
||||
if (mutex is null)
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@ namespace CommonHelpers
|
|||
return IsOSDForeground(out _);
|
||||
}
|
||||
|
||||
public static bool IsOSDForeground(out int? processId)
|
||||
public static bool IsOSDForeground(out int processId)
|
||||
{
|
||||
try
|
||||
{
|
||||
processId = (int?)GetTopLevelProcessId();
|
||||
if (processId is null)
|
||||
var id = GetTopLevelProcessId();
|
||||
processId = (int)id.GetValueOrDefault(0);
|
||||
if (id is null)
|
||||
return false;
|
||||
|
||||
foreach (var app in OSD.GetAppEntries(AppFlags.MASK))
|
||||
|
|
@ -28,7 +29,7 @@ namespace CommonHelpers
|
|||
}
|
||||
catch
|
||||
{
|
||||
processId = null;
|
||||
processId = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ namespace PowerControl.Menu
|
|||
public int ApplyDelay { get; set; }
|
||||
public bool CycleOptions { get; set; } = true;
|
||||
|
||||
public Func<object>? CurrentValue { get; set; }
|
||||
public Func<object[]>? OptionsValues { get; set; }
|
||||
public Func<object, object>? ApplyValue { get; set; }
|
||||
public Func<object>? ResetValue { get; set; }
|
||||
public Func<object?>? CurrentValue { get; set; }
|
||||
public Func<object[]?>? OptionsValues { get; set; }
|
||||
public Func<object, object?>? ApplyValue { get; set; }
|
||||
public Func<object?>? ResetValue { get; set; }
|
||||
|
||||
private System.Windows.Forms.Timer delayTimer = new System.Windows.Forms.Timer();
|
||||
private ToolStripMenuItem toolStripItem = new ToolStripMenuItem();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace PowerControl.Options
|
|||
return selected;
|
||||
}
|
||||
|
||||
sd.HardMinGfxClock = uint.Parse(selected.ToString().Replace("MHz", ""));
|
||||
sd.HardMinGfxClock = uint.Parse(selected.ToString()?.Replace("MHz", "") ?? "200");
|
||||
return selected;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace PowerControl.Options
|
|||
if (!ProcessorCores.HasSMTThreads())
|
||||
return null;
|
||||
|
||||
return ProcessorCores.IsUsingSMT(processId.Value) ? "Yes" : "No";
|
||||
return ProcessorCores.IsUsingSMT(processId) ? "Yes" : "No";
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
{
|
||||
|
|
@ -27,9 +27,9 @@ namespace PowerControl.Options
|
|||
if (!ProcessorCores.HasSMTThreads())
|
||||
return null;
|
||||
|
||||
ProcessorCores.SetProcessSMT(processId.Value, selected.ToString() == "Yes");
|
||||
ProcessorCores.SetProcessSMT(processId, selected.ToString() == "Yes");
|
||||
|
||||
return ProcessorCores.IsUsingSMT(processId.Value) ? "Yes" : "No";
|
||||
return ProcessorCores.IsUsingSMT(processId) ? "Yes" : "No";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,11 @@ namespace PowerControl.Options
|
|||
)
|
||||
return null;
|
||||
|
||||
uint mW = uint.Parse(selected.ToString().Replace("W", "")) * 1000;
|
||||
var selectedText = selected.ToString();
|
||||
if (selectedText is null)
|
||||
return null;
|
||||
|
||||
uint mW = uint.Parse(selectedText.Replace("W", "")) * 1000;
|
||||
|
||||
if (VangoghGPU.IsSupported)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue