[vlmc-devel] [PATCH] Restores settings to default values on closing project

Barun Parrucl barun.parruck at gmail.com
Thu Mar 10 16:15:58 CET 2016


From: Barun Parruck <barun.parruck at gmail.com>

Settings are now restored to default values when a project is closed.
---
 src/Project/Project.cpp   |  2 +-
 src/Settings/Settings.cpp | 10 +++++++++-
 src/Settings/Settings.h   |  1 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
index dee00e9..0401154 100644
--- a/src/Project/Project.cpp
+++ b/src/Project/Project.cpp
@@ -266,7 +266,7 @@ Project::closeProject()
 {
     if ( m_projectFile == nullptr )
         return;
-    // FIXME: Restore settings to their default value
+    m_settings->restoreDefaultValues();
     emit projectClosed();
     delete m_projectFile;
     m_projectFile = nullptr;
diff --git a/src/Settings/Settings.cpp b/src/Settings/Settings.cpp
index 2259228..0a16e1d 100644
--- a/src/Settings/Settings.cpp
+++ b/src/Settings/Settings.cpp
@@ -164,7 +164,15 @@ Settings::setValue(const QString &key, const QVariant &value)
     Q_ASSERT_X( false, __FILE__, "setting value without a created variable" );
     return false;
 }
-
+void
+Settings::restoreDefaultValues()
+{
+    QReadLocker lock( &m_rwLock );
+    for (auto it : m_settings)
+    {
+        (it)->restoreDefault();
+    }
+}
 SettingValue*
 Settings::value(const QString &key)
 {
diff --git a/src/Settings/Settings.h b/src/Settings/Settings.h
index 65d368a..b53533b 100644
--- a/src/Settings/Settings.h
+++ b/src/Settings/Settings.h
@@ -122,6 +122,7 @@ class   Settings : public ILoadSave
         bool                        load();
         bool                        save();
         bool                        save( QXmlStreamWriter& project );
+        void                        restoreDefaultValues();
         void                        setSettingsFile( const QString& settingsFile );
 
         bool                        load( const QDomDocument& document );
-- 
2.3.2 (Apple Git-55)



More information about the Vlmc-devel mailing list