mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-18 17:10:55 +02:00
Bug 2803 - Audacity unresponsive after 'Fit to Height'
a) Fixed root cause, which is conversion of a negative integer to a large unsigned, leading to a very tall track. b) Improved mitigation (in projects that already have over tall tracks) by setting a smaller minimum for the allowed size.
This commit is contained in:
parent
1b9e938869
commit
404ad6ad8a
@ -145,7 +145,12 @@ void DoZoomFitV(AudacityProject &project)
|
|||||||
- range.sum( TrackView::GetTrackHeight );
|
- range.sum( TrackView::GetTrackHeight );
|
||||||
|
|
||||||
// Give each resized track the average of the remaining height
|
// Give each resized track the average of the remaining height
|
||||||
height = height / count;
|
// Bug 2803: Cast count to int, because otherwise the result of
|
||||||
|
// division will be unsigned too, and will be a very large number
|
||||||
|
// if height was negative!
|
||||||
|
height = height / (int)count;
|
||||||
|
// Use max() so that we don't set a negative height when there is
|
||||||
|
// not enough room.
|
||||||
height = std::max( (int)TrackInfo::MinimumTrackHeight(), height );
|
height = std::max( (int)TrackInfo::MinimumTrackHeight(), height );
|
||||||
|
|
||||||
for (auto t : range)
|
for (auto t : range)
|
||||||
|
@ -97,10 +97,10 @@ bool TrackView::HandleXMLAttribute( const wxChar *attr, const wxChar *value )
|
|||||||
long nValue;
|
long nValue;
|
||||||
if (!wxStrcmp(attr, wxT("height")) &&
|
if (!wxStrcmp(attr, wxT("height")) &&
|
||||||
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
|
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
|
||||||
// Extreme values for track height (likely caused by integer overflow)
|
// Bug 2803: Extreme values for track height (caused by integer overflow)
|
||||||
// will stall Audacity as it tries to create an enormous vertical ruler.
|
// will stall Audacity as it tries to create an enormous vertical ruler.
|
||||||
// So clamp to reasonable values.
|
// So clamp to reasonable values.
|
||||||
nValue = std::max( 150l, std::min( nValue, 1000l ));
|
nValue = std::max( 40l, std::min( nValue, 1000l ));
|
||||||
SetHeight(nValue);
|
SetHeight(nValue);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user