[vlmc-devel] [PATCH 2/3] Fix QTimer running with its interval of 0

Yikai Lu luyikei.qmltu at gmail.com
Mon Mar 7 12:43:43 CET 2016


By letting SettingValue "setLimits" and making it Clamped, we avoid it being 0.

Also, have QTimer run with the interval saved as SettingValue, not just start()
---
 src/Project/Project.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
index 3800e51..c37a0ae 100644
--- a/src/Project/Project.cpp
+++ b/src/Project/Project.cpp
@@ -60,7 +60,8 @@ Project::Project( Settings* settings )
     SettingValue    *automaticBackupInterval = settings->createVar( SettingValue::Int, "vlmc/AutomaticBackupInterval", 5,
                                     QT_TRANSLATE_NOOP( "PreferenceWidget", "Automatic save interval" ),
                                     QT_TRANSLATE_NOOP( "PreferenceWidget", "This is the interval that VLMC will wait "
-                                                       "between two automatic save" ), SettingValue::Nothing );
+                                                       "between two automatic save" ), SettingValue::Clamped );
+    automaticBackupInterval->setLimits(1, QVariant(QVariant::Invalid));
 
     connect( m_timer, SIGNAL( timeout() ), this, SLOT(autoSaveRequired() ) );
     connect( this, SIGNAL( destroyed() ), m_timer, SLOT( stop() ) );
@@ -70,7 +71,7 @@ Project::Project( Settings* settings )
     connect( automaticBackupInterval, SIGNAL( changed( QVariant ) ), this,
              SLOT( autoSaveIntervalChanged( QVariant ) ) );
 
-    m_timer->start();
+    m_timer->start( automaticBackupInterval->get().toInt() * 1000 * 60 );
 }
 
 Project::~Project()
-- 
1.9.1



More information about the Vlmc-devel mailing list