diff options
author | MerryMage <MerryMage@users.noreply.github.com> | 2016-03-02 13:49:30 +0100 |
---|---|---|
committer | MerryMage <MerryMage@users.noreply.github.com> | 2016-03-02 15:25:06 +0100 |
commit | 48366b1071a7e6ee367435b78845b429c0c9c31f (patch) | |
tree | ea8830afe35efaed11cc820c83ab798fe5a9af36 /src/citra | |
parent | Dependencies: Remove GLFW, Add SDL2 (diff) | |
download | yuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.tar yuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.tar.gz yuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.tar.bz2 yuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.tar.lz yuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.tar.xz yuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.tar.zst yuzu-48366b1071a7e6ee367435b78845b429c0c9c31f.zip |
Diffstat (limited to 'src/citra')
-rw-r--r-- | src/citra/config.cpp | 18 | ||||
-rw-r--r-- | src/citra/config.h | 8 |
2 files changed, 12 insertions, 14 deletions
diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 91c0df425..9034b188e 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -10,6 +10,7 @@ #include "common/file_util.h" #include "common/logging/log.h" +#include "common/make_unique.h" #include "core/settings.h" @@ -18,20 +19,21 @@ Config::Config() { // TODO: Don't hardcode the path; let the frontend decide where to put the config files. sdl2_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "sdl2-config.ini"; - sdl2_config = new INIReader(sdl2_config_loc); + sdl2_config = Common::make_unique<INIReader>(sdl2_config_loc); Reload(); } -bool Config::LoadINI(INIReader* config, const char* location, const std::string& default_contents, bool retry) { - if (config->ParseError() < 0) { +bool Config::LoadINI(const std::string& default_contents, bool retry) { + const char* location = this->sdl2_config_loc.c_str(); + if (sdl2_config->ParseError() < 0) { if (retry) { LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location); FileUtil::CreateFullPath(location); FileUtil::WriteStringToFile(true, default_contents, location); - *config = INIReader(location); // Reopen file + sdl2_config = Common::make_unique<INIReader>(location); // Reopen file - return LoadINI(config, location, default_contents, false); + return LoadINI(default_contents, false); } LOG_ERROR(Config, "Failed."); return false; @@ -82,10 +84,6 @@ void Config::ReadValues() { } void Config::Reload() { - LoadINI(sdl2_config, sdl2_config_loc.c_str(), DefaultINI::sdl2_config_file); + LoadINI(DefaultINI::sdl2_config_file); ReadValues(); } - -Config::~Config() { - delete sdl2_config; -} diff --git a/src/citra/config.h b/src/citra/config.h index d87ef7883..52a478146 100644 --- a/src/citra/config.h +++ b/src/citra/config.h @@ -4,19 +4,19 @@ #pragma once +#include <memory> #include <string> -class INIReader; +#include <inih/cpp/INIReader.h> class Config { - INIReader* sdl2_config; + std::unique_ptr<INIReader> sdl2_config; std::string sdl2_config_loc; - bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true); + bool LoadINI(const std::string& default_contents="", bool retry=true); void ReadValues(); public: Config(); - ~Config(); void Reload(); }; |