From bf6dd783247b60e7e372d76e5095e7476223b98e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 23 Oct 2018 21:49:50 -0400 Subject: [PATCH] yuzu/configuration/config: Use a std::unique_ptr for qt_config instead of a raw pointer Same behavior, less code. --- src/citra_qt/configuration/config.cpp | 13 ++++++------- src/citra_qt/configuration/config.h | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index a7c284471c..3004fa9364 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -16,11 +16,16 @@ Config::Config() { // TODO: Don't hardcode the path; let the frontend decide where to put the config files. qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini"; FileUtil::CreateFullPath(qt_config_loc); - qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat); + qt_config = + std::make_unique(QString::fromStdString(qt_config_loc), QSettings::IniFormat); Reload(); } +Config::~Config() { + Save(); +} + const std::array Config::default_buttons = { Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H, Qt::Key_Q, Qt::Key_W, Qt::Key_M, Qt::Key_N, Qt::Key_1, Qt::Key_2, Qt::Key_B, @@ -561,9 +566,3 @@ void Config::Reload() { void Config::Save() { SaveValues(); } - -Config::~Config() { - Save(); - - delete qt_config; -} diff --git a/src/citra_qt/configuration/config.h b/src/citra_qt/configuration/config.h index 1108926c54..fdb161c238 100644 --- a/src/citra_qt/configuration/config.h +++ b/src/citra_qt/configuration/config.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include #include "core/settings.h" @@ -30,6 +31,6 @@ private: void WriteSetting(const QString& name, const QVariant& value); void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value); - QSettings* qt_config; + std::unique_ptr qt_config; std::string qt_config_loc; };