diff options
| author | 2018-10-24 18:07:14 -0400 | |
|---|---|---|
| committer | 2018-10-24 18:07:14 -0400 | |
| commit | 3a6e76e9b56db63f3f444c13e97d62124b94f31d (patch) | |
| tree | 4b1b12418a6023edc829cd44ad463d749e7464b8 | |
| parent | Merge pull request #1565 from lioncash/audio (diff) | |
| parent | yuzu/configuration/config: Use a std::unique_ptr for qt_config instead of a r... (diff) | |
| download | yuzu-3a6e76e9b56db63f3f444c13e97d62124b94f31d.tar.gz yuzu-3a6e76e9b56db63f3f444c13e97d62124b94f31d.tar.xz yuzu-3a6e76e9b56db63f3f444c13e97d62124b94f31d.zip | |
Merge pull request #1558 from lioncash/ptr
yuzu/configuration/config: Use a std::unique_ptr for qt_config instead of a raw pointer
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 13 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.h | 14 |
2 files changed, 14 insertions, 13 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 1fe9a7edd..d4fd60a73 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -13,11 +13,16 @@ Config::Config() { | |||
| 13 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | 13 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. |
| 14 | qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini"; | 14 | qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini"; |
| 15 | FileUtil::CreateFullPath(qt_config_loc); | 15 | FileUtil::CreateFullPath(qt_config_loc); |
| 16 | qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat); | 16 | qt_config = |
| 17 | std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat); | ||
| 17 | 18 | ||
| 18 | Reload(); | 19 | Reload(); |
| 19 | } | 20 | } |
| 20 | 21 | ||
| 22 | Config::~Config() { | ||
| 23 | Save(); | ||
| 24 | } | ||
| 25 | |||
| 21 | const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = { | 26 | const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = { |
| 22 | Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_3, Qt::Key_4, Qt::Key_Q, | 27 | Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_3, Qt::Key_4, Qt::Key_Q, |
| 23 | Qt::Key_W, Qt::Key_1, Qt::Key_2, Qt::Key_N, Qt::Key_M, Qt::Key_F, Qt::Key_T, | 28 | Qt::Key_W, Qt::Key_1, Qt::Key_2, Qt::Key_N, Qt::Key_M, Qt::Key_F, Qt::Key_T, |
| @@ -342,9 +347,3 @@ void Config::Reload() { | |||
| 342 | void Config::Save() { | 347 | void Config::Save() { |
| 343 | SaveValues(); | 348 | SaveValues(); |
| 344 | } | 349 | } |
| 345 | |||
| 346 | Config::~Config() { | ||
| 347 | Save(); | ||
| 348 | |||
| 349 | delete qt_config; | ||
| 350 | } | ||
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index cbf745ea2..9c99c1b75 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <memory> | ||
| 8 | #include <string> | 9 | #include <string> |
| 9 | #include <QVariant> | 10 | #include <QVariant> |
| 10 | #include "core/settings.h" | 11 | #include "core/settings.h" |
| @@ -12,12 +13,6 @@ | |||
| 12 | class QSettings; | 13 | class QSettings; |
| 13 | 14 | ||
| 14 | class Config { | 15 | class Config { |
| 15 | QSettings* qt_config; | ||
| 16 | std::string qt_config_loc; | ||
| 17 | |||
| 18 | void ReadValues(); | ||
| 19 | void SaveValues(); | ||
| 20 | |||
| 21 | public: | 16 | public: |
| 22 | Config(); | 17 | Config(); |
| 23 | ~Config(); | 18 | ~Config(); |
| @@ -27,4 +22,11 @@ public: | |||
| 27 | 22 | ||
| 28 | static const std::array<int, Settings::NativeButton::NumButtons> default_buttons; | 23 | static const std::array<int, Settings::NativeButton::NumButtons> default_buttons; |
| 29 | static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs; | 24 | static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs; |
| 25 | |||
| 26 | private: | ||
| 27 | void ReadValues(); | ||
| 28 | void SaveValues(); | ||
| 29 | |||
| 30 | std::unique_ptr<QSettings> qt_config; | ||
| 31 | std::string qt_config_loc; | ||
| 30 | }; | 32 | }; |