From 82968f9cba6d74294fdcacfac9e844d5dfead3cb Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Sat, 23 Aug 2008 03:47:03 +0000 Subject: [PATCH] Fix various casting warnings git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1471 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 8 ++++++++ include/automatable_model.h | 4 ++-- src/core/lfo_controller.cpp | 14 ++++++++------ src/gui/automation_editor.cpp | 2 +- src/gui/lmms_style.cpp | 6 +++--- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0267d3140..4441ba844 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-08-18 Paul Giblock + + * include/automatable_model.h: + * src/gui/automation_editor.cpp: + * src/gui/lmms_style.cpp: + * src/core/lfo_controller.cpp: + Fix various casting warnings + 2008-08-22 Tobias Doerffel * src/core/main.cpp: diff --git a/include/automatable_model.h b/include/automatable_model.h index 800b13d82..979e990c1 100644 --- a/include/automatable_model.h +++ b/include/automatable_model.h @@ -118,13 +118,13 @@ public: { if( m_controllerConnection != NULL ) { - const float v = minValue() + + const T v = minValue() + castValue( m_range * m_controllerConnection->currentValue( _frameOffset ) ); if( m_step == 1 ) { - return( roundf( v ) ); + return( castValue( roundf( v ) ) ); } return( v ); } diff --git a/src/core/lfo_controller.cpp b/src/core/lfo_controller.cpp index 538fcee7b..8475afb46 100644 --- a/src/core/lfo_controller.cpp +++ b/src/core/lfo_controller.cpp @@ -90,25 +90,27 @@ float lfoController::value( int _offset ) // The new duration in frames // (Samples/Second) / (periods/second) = (Samples/cycle) - int newDuration = static_cast( - (engine::getMixer()->processingSampleRate()) * - m_speedModel.value() ); + float newDurationF = + engine::getMixer()->processingSampleRate() * + m_speedModel.value(); switch(m_multiplierModel.value() ) { case 1: - newDuration /= 100.0; + newDurationF /= 100.0; break; case 2: - newDuration *= 100.0; + newDurationF *= 100.0; break; default: break; } - m_phaseOffset = m_phaseModel.value() * newDuration / (360.0); + m_phaseOffset = static_cast( + m_phaseModel.value() * newDurationF / 360.0 ); + int newDuration = static_cast( newDurationF ); if (newDuration != m_duration) { // frame offset diff --git a/src/gui/automation_editor.cpp b/src/gui/automation_editor.cpp index 7ea1016f1..072e12b72 100644 --- a/src/gui/automation_editor.cpp +++ b/src/gui/automation_editor.cpp @@ -642,7 +642,7 @@ void automationEditor::leaveEvent( QEvent * _e ) void automationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 ) { - int deltax = tAbs( _x1 - _x0 ); + int deltax = static_cast( tAbs( _x1 - _x0 ) ); float deltay = tAbs( _y1 - _y0 ); int x = _x0; float y = _y0; diff --git a/src/gui/lmms_style.cpp b/src/gui/lmms_style.cpp index 17910d04c..9b86c7893 100644 --- a/src/gui/lmms_style.cpp +++ b/src/gui/lmms_style.cpp @@ -61,9 +61,9 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element, QColor highlight = option->palette.highlight().color(); int a100 = 165; - int a75 = a100 * .75; - int a50 = a100 * .6; - int a25 = a100 * .33; + int a75 = static_cast( a100 * .75 ); + int a50 = static_cast( a100 * .6 ); + int a25 = static_cast( a100 * .33 ); QLine lines[4]; QPoint points[4];