Fixed a NullReferenceException in the NvidiaGPU class.

This commit is contained in:
Michael Möller 2020-02-27 22:07:24 +01:00
parent 77908f1d99
commit 6dc0e141c3

View File

@ -96,7 +96,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
if (NVML.IsInitialized) { if (NVML.IsInitialized) {
if (NVAPI.NvAPI_GPU_GetBusId != null && if (NVAPI.NvAPI_GPU_GetBusId != null &&
NVAPI.NvAPI_GPU_GetBusId(handle, out uint busId) == NvStatus.OK) { NVAPI.NvAPI_GPU_GetBusId(handle, out uint busId) == NvStatus.OK) {
if (NVML.NvmlDeviceGetHandleByPciBusId( if (NVML.NvmlDeviceGetHandleByPciBusId != null &&
NVML.NvmlDeviceGetHandleByPciBusId(
"0000:" + busId.ToString("X2") + ":00.0", out var result) "0000:" + busId.ToString("X2") + ":00.0", out var result)
== NVML.NvmlReturn.Success) == NVML.NvmlReturn.Success)
{ {
@ -185,8 +186,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
sensor.Value = settings.Sensor[sensor.Index].CurrentTemp; sensor.Value = settings.Sensor[sensor.Index].CurrentTemp;
bool tachReadingOk = false; bool tachReadingOk = false;
if (fan != null && NVAPI.NvAPI_GPU_GetTachReading(handle, out int fanValue) if (NVAPI.NvAPI_GPU_GetTachReading != null &&
== NvStatus.OK) NVAPI.NvAPI_GPU_GetTachReading(handle, out int fanValue) == NvStatus.OK)
{ {
fan.Value = fanValue; fan.Value = fanValue;
ActivateSensor(fan); ActivateSensor(fan);