AutomatableModel: do not return an out of range value in fittedValue()

If a certain step was set for a model, the fitted value (i.e. value
divided by step, rounded and multiplied with step again) could become
smaller than minValue or greater than maxValue. Therefore explicitely
check those cases after performing the described calculation.

Closes #2840202.
(cherry picked from commit b5d9fab944)
This commit is contained in:
Tobias Doerffel
2009-08-23 23:32:11 +02:00
parent 2f8b9c5a61
commit 6a8b285932

View File

@@ -1,8 +1,8 @@
/*
* automatable_model.cpp - some implementations of automatableModel-class
*
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -305,6 +305,15 @@ float automatableModel::fittedValue( float _value ) const
_value = 0;
}
if( _value < m_minValue )
{
return m_minValue;
}
else if( _value > m_maxValue )
{
return m_maxValue;
}
return _value;
}