From ab9c024a614bd3657bd5cd74cddc7755c0e0d01a Mon Sep 17 00:00:00 2001 From: Lesueur Benjamin Date: Fri, 27 Dec 2024 09:13:33 +0100 Subject: [PATCH] Fixed an issue causing a crash on controller disconnect --- HandheldCompanion/Controllers/IController.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/HandheldCompanion/Controllers/IController.cs b/HandheldCompanion/Controllers/IController.cs index 52dd3fd69..eeb31f6b6 100644 --- a/HandheldCompanion/Controllers/IController.cs +++ b/HandheldCompanion/Controllers/IController.cs @@ -325,9 +325,9 @@ public virtual void Unplug() public bool IsHidden() { - // bool hide_device = HidHide.IsRegistered(Details.deviceInstanceId); - bool hide_base = HidHide.IsRegistered(Details.baseContainerDeviceInstanceId); - return /* hide_device || */ hide_base; + if (Details is not null) + return HidHide.IsRegistered(Details.baseContainerDeviceInstanceId); + return false; } public virtual void Hide(bool powerCycle = true) @@ -383,12 +383,18 @@ public virtual void SetLightColor(byte R, byte G, byte B) protected void HideHID() { + if (Details is null) + return; + HidHide.HidePath(Details.baseContainerDeviceInstanceId); HidHide.HidePath(Details.deviceInstanceId); } protected void UnhideHID() { + if (Details is null) + return; + HidHide.UnhidePath(Details.baseContainerDeviceInstanceId); HidHide.UnhidePath(Details.deviceInstanceId); }