From 6a8b285932e67dc2bd0f0c8fae089592b43f9f38 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 23 Aug 2009 23:32:11 +0200 Subject: [PATCH] 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 b5d9fab944f14df502e203a6c89a48dbe205be6d) --- src/core/automatable_model.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/core/automatable_model.cpp b/src/core/automatable_model.cpp index 43210d5b0..2723bfe57 100644 --- a/src/core/automatable_model.cpp +++ b/src/core/automatable_model.cpp @@ -1,8 +1,8 @@ /* * automatable_model.cpp - some implementations of automatableModel-class * - * Copyright (c) 2008 Tobias Doerffel - * + * Copyright (c) 2008-2009 Tobias Doerffel + * * 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; }