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.)
master
Glenn Maynard 6 years ago
parent aba274603c
commit 478a0618fb
  1. 2
      smx-config/Helpers.cs
  2. 13
      smx-config/SMX.cs

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

@ -192,6 +192,19 @@ namespace SMX
panelThreshold7High = values[7];
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

Loading…
Cancel
Save