Potential fix for a race.
Do proper bounds checks and force the use of operator[] () const
This commit is contained in:
parent
16d6791566
commit
af875e0edc
@ -601,23 +601,28 @@ void ContourDesignControlProtocol::jump_backward (JumpDistance dist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ContourDesignControlProtocol::set_shuttle_speed (int index, double speed)
|
ContourDesignControlProtocol::set_shuttle_speed (unsigned int index, double speed)
|
||||||
{
|
{
|
||||||
/* called from GUI thread */
|
if (index >= _shuttle_speeds.size()) {
|
||||||
// XXX this may race with ContourDesignControlProtocol::shuttle_event()
|
return;
|
||||||
// TODO: add bounds check
|
}
|
||||||
_shuttle_speeds[index] = speed;
|
_shuttle_speeds[index] = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ContourDesignControlProtocol::shuttle_event(int position)
|
ContourDesignControlProtocol::shuttle_event (int position)
|
||||||
{
|
{
|
||||||
DEBUG_TRACE (DEBUG::ContourDesignControl, string_compose ("shuttle event %1\n", position));
|
if (abs(position) > num_shuttle_speeds) {
|
||||||
|
DEBUG_TRACE (DEBUG::ContourDesignControl, "received invalid shuttle position... ignoring.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (position != 0) {
|
if (position != 0) {
|
||||||
if (_shuttle_was_zero) {
|
if (_shuttle_was_zero) {
|
||||||
_was_rolling_before_shuttle = session->transport_rolling ();
|
_was_rolling_before_shuttle = session->transport_rolling ();
|
||||||
}
|
}
|
||||||
double speed = position > 0 ? _shuttle_speeds[position-1] : -_shuttle_speeds[-position-1];
|
const vector<double>& spds = _shuttle_speeds;
|
||||||
|
const double speed = position > 0 ? spds[position-1] : -spds[-position-1];
|
||||||
set_transport_speed (speed);
|
set_transport_speed (speed);
|
||||||
_shuttle_was_zero = false;
|
_shuttle_was_zero = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,8 +114,8 @@ public:
|
|||||||
JumpDistance jog_distance () const { return _jog_distance; }
|
JumpDistance jog_distance () const { return _jog_distance; }
|
||||||
void set_jog_distance (JumpDistance jd) { _jog_distance = jd; }
|
void set_jog_distance (JumpDistance jd) { _jog_distance = jd; }
|
||||||
|
|
||||||
void set_shuttle_speed (int index, double speed);
|
void set_shuttle_speed (unsigned int index, double speed);
|
||||||
double shuttle_speed (int index) const {
|
double shuttle_speed (unsigned int index) const {
|
||||||
return _shuttle_speeds[index];
|
return _shuttle_speeds[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user