Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Commit

Permalink
Fix QSettings issue on Windows 7
Browse files Browse the repository at this point in the history
Regression related to issue #168
  • Loading branch information
CDuquesnoy committed Jan 7, 2018
1 parent c598be3 commit a02235c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/lib/MellowPlayer/Infrastructure/Settings/QSettingsStore.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
#include "QSettingsStore.hpp"
#include <QDebug>

using namespace MellowPlayer::Domain;
using namespace MellowPlayer::Domain;
using namespace MellowPlayer::Infrastructure;
using namespace std;

QSettingsStore::QSettingsStore(const QString& orgName) : qSettings_(orgName, "3")
QSettingsStore::QSettingsStore() : qSettings_(make_unique<QSettings>("MellowPlayer", "3"))
{
}

void QSettingsStore::setOrganizationName(const QString &orgName)
{
qSettings_ = make_unique<QSettings>(orgName, "3");
}

void QSettingsStore::clear()
{
qSettings_.clear();
qSettings_->clear();
}

QVariant QSettingsStore::value(const QString& key, const QVariant& defaultValue) const
{
return qSettings_.value(key, defaultValue);
return qSettings_->value(key, defaultValue);
}

void QSettingsStore::setValue(const QString& key, const QVariant& value)
{
qSettings_.setValue(key, value);
qSettings_->setValue(key, value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ namespace MellowPlayer::Infrastructure
class QSettingsStore : public Domain::ISettingsStore
{
public:
QSettingsStore(const QString& orgName="MellowPlayer");
QSettingsStore();

void setOrganizationName(const QString& orgName);

void clear() override;

QVariant value(const QString& key, const QVariant& defaultValue = QVariant()) const override;
void setValue(const QString& key, const QVariant& value) override;

private:
QSettings qSettings_;
std::unique_ptr<QSettings> qSettings_;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ using namespace MellowPlayer::Infrastructure;

TEST_CASE("QSettingsStoreTests")
{
QSettingsStore qSettingsStore("MellowPlayer.Tests");
QSettingsStore qSettingsStore();
qSettingsStore.setOrganizationName("MellowPlayer.Tests");

SECTION("defaultValue")
{
Expand Down

0 comments on commit a02235c

Please sign in to comment.