From 0d957b0bfa8db44336206cbc973e2f0b7f595631 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 25 Mar 2019 21:38:08 -0500 Subject: [PATCH] Added null check for method. Should help prevent crashing on a quick connect and disconnect caused by a bad USB cable --- DS4Windows/DS4Forms/DS4Form.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 93745b8..b65af28 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -1405,6 +1405,11 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question private void Enable_Controls(int device, bool on) { + DS4Device dev = Program.rootHub.DS4Controllers[device]; + ConnectionType conType = ConnectionType.USB; + if (dev != null) + conType = dev.ConnectionType; + Pads[device].Visible = on; ebns[device].Visible = on; lights[device].Visible = on; @@ -1412,8 +1417,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question shortcuts[device].Visible = on; Batteries[device].Visible = on; linkedProfileCB[device].Visible = on; - disconnectShortcuts[device].Visible = on && - Program.rootHub.DS4Controllers[device].ConnectionType != ConnectionType.USB; + disconnectShortcuts[device].Visible = on && conType != ConnectionType.USB; } protected void On_Debug(object sender, DebugEventArgs e)