[vlmc-devel] commit: SettingValue: Handle flags in the SettingValue::set ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Mon Jul 26 22:15:18 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Mon Jul 26 11:56:11 2010 +0200| [646b43c4345581bc879a5a7ed1c4d477c0656734] | committer: Hugo Beauzée-Luyssen 

SettingValue: Handle flags in the SettingValue::set

This is to ensure the value won't be incoherent, as it was only checked
in the GUI

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=646b43c4345581bc879a5a7ed1c4d477c0656734
---

 src/Settings/SettingValue.cpp |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/Settings/SettingValue.cpp b/src/Settings/SettingValue.cpp
index 39b4d8f..9568b6e 100644
--- a/src/Settings/SettingValue.cpp
+++ b/src/Settings/SettingValue.cpp
@@ -35,10 +35,20 @@ SettingValue::SettingValue( SettingValue::Type type, const QVariant& defaultValu
 }
 
 void
-SettingValue::set( const QVariant& val )
+SettingValue::set( const QVariant& _val )
 {
+    QVariant val = _val;
     if ( val != m_val )
     {
+        if ( ( m_flags & Clamped ) != 0 )
+        {
+            if ( m_min.isValid() && val.toDouble() < m_min.toDouble() )
+                val = m_min;
+            if ( m_max.isValid() && val.toDouble() > m_max.toDouble() )
+                val = m_max;
+        }
+        if ( ( m_flags & EightMultiple ) != 0 )
+            val = ( val.toInt() + 7 ) & ~7;
         m_val = val;
         emit changed( m_val );
     }



More information about the Vlmc-devel mailing list