[vlmc-devel] [PATCH] Restores settings to default values on closing project
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Fri Mar 11 11:03:32 CET 2016
On 03/10/2016 04:15 PM, Barun Parrucl wrote:
> 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();
This is nitpicking, but the parenthesis aren't required here.
Also, you're not handling an iterator anymore, but the actual value. I
took the liberty of ammending your patch, and will apply the updated
version.
> + }
> +}
> 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 );
>
Thanks!
More information about the Vlmc-devel
mailing list