Fix exception if ThresholdSlider refreshes when no pads are active.

GetFirstActivePadConfig returns a dummy config if nothing is connected, which
didn't have any of its arrays created.  Fill in dummy arrays for enabledSensors,
etc. so refreshes don't throw exceptions if they're updated right when the
last controller disconnects.  (This is a rare race condition and I've only
seen it while stepping in the debugger and disconnecting while stopped.)
This commit is contained in:
Glenn Maynard 2018-12-29 22:10:27 -06:00
parent aba274603c
commit 478a0618fb
2 changed files with 14 additions and 1 deletions

View File

@ -64,7 +64,7 @@ namespace smx_config
// There aren't any pads connected. Just return a dummy config, since the UI // There aren't any pads connected. Just return a dummy config, since the UI
// isn't visible. // isn't visible.
return new SMX.SMXConfig(); return SMX.SMXConfig.Create();
} }
public static SMX.SMXConfig GetFirstActivePadConfig() public static SMX.SMXConfig GetFirstActivePadConfig()

View File

@ -192,6 +192,19 @@ namespace SMX
panelThreshold7High = values[7]; panelThreshold7High = values[7];
panelThreshold8High = values[8]; panelThreshold8High = values[8];
} }
// Create an empty SMXConfig.
static public SMXConfig Create()
{
SMXConfig result = new SMXConfig();
result.enabledSensors = new Byte[5];
result.stepColor = new Byte[3*9];
result.individualPanelFSRLow = new UInt16[9];
result.individualPanelFSRHigh = new UInt16[9];
result.platformStripColor = new Byte[3];
return result;
}
}; };
public struct SMXSensorTestModeData public struct SMXSensorTestModeData