Fix crashes when moving mouse over port-matrix
Beware of using float as loop/while variable. When moving the mouse over the tilted port-label area the position p is set to ` p - (_height - o) * tan (angle ())`. In optimized (fast math) builds this can be come negative (-0.0). `::type_channel_to_overall()` then returns a negative channel count, leading to a crash. And in some edge-cases (literally moving the mouse to the edge after resizing the window on Intel Mac), PortMatrixColumnLabels::motion is called and the port corresponding to the mouse-position is also computed to be negative.
This commit is contained in:
@@ -495,7 +495,7 @@ PortMatrixColumnLabels::motion (double x, double y)
|
||||
{
|
||||
ARDOUR::BundleChannel const w = position_to_channel (x, y, _matrix->visible_columns());
|
||||
|
||||
if (w.bundle == 0) {
|
||||
if (!w.bundle) {
|
||||
_body->set_mouseover (PortMatrixNode ());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,10 @@ PortMatrixComponent::position_to_channel (double p, double, std::shared_ptr<cons
|
||||
ARDOUR::ChanCount const N = (*j)->bundle->nchannels ();
|
||||
|
||||
uint32_t const s = _matrix->count_of_our_type_min_1 (N);
|
||||
if (p < s) {
|
||||
|
||||
if (p < 0) {
|
||||
break;
|
||||
} else if (p < s) {
|
||||
if (p < _matrix->count_of_our_type (N)) {
|
||||
return ARDOUR::BundleChannel ((*j)->bundle, (*j)->bundle->type_channel_to_overall (_matrix->type (), p));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user