1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Mouse wheel caused hang.

mScrollRemainder was not getting initialised and so the first time TimeTextCtrl::OnMouse got called, 'steps' got set to a random number (very large and -ve here) and Adjust got called with -2147483648, -1.  So we need to initialise mScrollRemainder.

This has been wrong for a while, from what I see.  Previous version used Decrease and Increase which were immune to the problem.

'Adjust' decrements steps, whether it is positive or negative to start with.  It is designed to have 'steps' strictly positive, so make sure of that.

Make sure OnMouse uses Adjust correctly.
This commit is contained in:
martynshaw99 2013-10-26 21:29:51 +00:00
parent 0bb9467cd6
commit 1092d982ee

View File

@ -824,6 +824,9 @@ void TimeConverter::Decrement()
void TimeConverter::Adjust(int steps, int dir)
{
wxASSERT(dir == -1 || dir == 1);
wxASSERT(steps > 0);
if (steps < 0)
steps = -steps;
while (steps != 0)
{
@ -940,6 +943,8 @@ TimeTextCtrl::TimeTextCtrl(wxWindow *parent,
//mchinen - aug 15 09 - this seems to put the mTimeValue back to zero, and do nothing else.
//ControlsToValue();
mScrollRemainder = 0.0;
#if wxUSE_ACCESSIBILITY
SetLabel(wxT(""));
SetName(wxT(""));
@ -1281,7 +1286,7 @@ void TimeTextCtrl::OnMouse(wxMouseEvent &event)
mScrollRemainder = steps - floor(steps);
steps = floor(steps);
Adjust((int)steps, steps < 0.0 ? -1 : 1);
Adjust((int)fabs(steps), steps < 0.0 ? -1 : 1);
Updated();
}
}