Browse Source

Fixing a crash in the Joystick class. (#3701)

QGC4.4
Gus Grubba 9 years ago committed by Don Gagne
parent
commit
196153aa47
  1. 5
      src/Joystick/Joystick.cc
  2. 2
      src/Joystick/Joystick.h

5
src/Joystick/Joystick.cc

@ -42,7 +42,6 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC
, _rgAxisValues(NULL) , _rgAxisValues(NULL)
, _rgCalibration(NULL) , _rgCalibration(NULL)
, _rgButtonValues(NULL) , _rgButtonValues(NULL)
, _rgButtonActions(NULL)
, _lastButtonBits(0) , _lastButtonBits(0)
, _throttleMode(ThrottleModeCenterZero) , _throttleMode(ThrottleModeCenterZero)
, _activeVehicle(NULL) , _activeVehicle(NULL)
@ -53,7 +52,6 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC
_rgAxisValues = new int[_axisCount]; _rgAxisValues = new int[_axisCount];
_rgCalibration = new Calibration_t[_axisCount]; _rgCalibration = new Calibration_t[_axisCount];
_rgButtonValues = new bool[_totalButtonCount]; _rgButtonValues = new bool[_totalButtonCount];
_rgButtonActions = new QString[_totalButtonCount];
for (int i=0; i<_axisCount; i++) { for (int i=0; i<_axisCount; i++) {
_rgAxisValues[i] = 0; _rgAxisValues[i] = 0;
@ -70,7 +68,6 @@ Joystick::~Joystick()
delete _rgAxisValues; delete _rgAxisValues;
delete _rgCalibration; delete _rgCalibration;
delete _rgButtonValues; delete _rgButtonValues;
delete _rgButtonActions;
} }
void Joystick::_loadSettings(void) void Joystick::_loadSettings(void)
@ -126,7 +123,7 @@ void Joystick::_loadSettings(void)
} }
for (int button=0; button<_buttonCount; button++) { for (int button=0; button<_buttonCount; button++) {
_rgButtonActions[button] = settings.value(QString(_buttonActionSettingsKey).arg(button), QString()).toString(); _rgButtonActions << settings.value(QString(_buttonActionSettingsKey).arg(button), QString()).toString();
qCDebug(JoystickLog) << "_loadSettings button:action" << button << _rgButtonActions[button]; qCDebug(JoystickLog) << "_loadSettings button:action" << button << _rgButtonActions[button];
} }

2
src/Joystick/Joystick.h

@ -163,7 +163,7 @@ protected:
int _rgFunctionAxis[maxFunction]; int _rgFunctionAxis[maxFunction];
bool* _rgButtonValues; bool* _rgButtonValues;
QString* _rgButtonActions; QStringList _rgButtonActions;
quint16 _lastButtonBits; quint16 _lastButtonBits;
ThrottleMode_t _throttleMode; ThrottleMode_t _throttleMode;

Loading…
Cancel
Save