Commit ddf699bb authored by luyikei's avatar luyikei

Settings: Use unique_ptr for m_settingsFile

parent 9bf70872
......@@ -55,13 +55,11 @@ Settings::Settings( const QString &settingsFile )
Settings::~Settings()
{
qDeleteAll( m_settings );
delete m_settingsFile;
}
void
Settings::setSettingsFile( const QString &settingsFile )
{
delete m_settingsFile;
if ( settingsFile.isEmpty() == false )
{
QFileInfo fInfo( settingsFile );
......@@ -71,10 +69,10 @@ Settings::setSettingsFile( const QString &settingsFile )
if ( dir.exists() == false )
dir.mkpath( fInfo.absolutePath() );
}
m_settingsFile = new QFile( settingsFile );
m_settingsFile.reset( new QFile( settingsFile ) );
}
else
m_settingsFile = nullptr;
m_settingsFile.release();
}
QJsonDocument
......
......@@ -27,6 +27,8 @@
#include "Project/Project.h"
#include "SettingValue.h"
#include <memory>
#include <QString>
#include <QMap>
#include <QPair>
......@@ -125,7 +127,7 @@ class Settings: public QObject
private:
SettingMap m_settings;
mutable QReadWriteLock m_rwLock;
QFile* m_settingsFile;
std::unique_ptr<QFile> m_settingsFile;
QList<QPair<QString, Settings*>> m_settingsChildren;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment