summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-10-24 09:25:13 -0400
committerGravatar Zach Hilman2018-10-24 09:25:20 -0400
commite7ac42677be6c13e5286fb42004aa94b0da45391 (patch)
tree91982bf07856c1de33d99f7187665b5c481be04f /src
parentprofile_manager: Create save data if it doesn't exist on use (diff)
downloadyuzu-e7ac42677be6c13e5286fb42004aa94b0da45391.tar.gz
yuzu-e7ac42677be6c13e5286fb42004aa94b0da45391.tar.xz
yuzu-e7ac42677be6c13e5286fb42004aa94b0da45391.zip
configure_system: Clear current username before overwriting
Prevents bug where old username would remain if the new username was shorter in length.
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/configure_system.cpp14
-rw-r--r--src/yuzu/configuration/configure_system.h6
2 files changed, 15 insertions, 5 deletions
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp
index a88fabc36..83cc49dfc 100644
--- a/src/yuzu/configuration/configure_system.cpp
+++ b/src/yuzu/configuration/configure_system.cpp
@@ -15,6 +15,7 @@
15#include "common/logging/backend.h" 15#include "common/logging/backend.h"
16#include "common/string_util.h" 16#include "common/string_util.h"
17#include "core/core.h" 17#include "core/core.h"
18#include "core/hle/service/acc/profile_manager.h"
18#include "core/settings.h" 19#include "core/settings.h"
19#include "ui_configure_system.h" 20#include "ui_configure_system.h"
20#include "yuzu/configuration/configure_system.h" 21#include "yuzu/configuration/configure_system.h"
@@ -266,6 +267,7 @@ void ConfigureSystem::RenameUser() {
266 if (!ok) 267 if (!ok)
267 return; 268 return;
268 269
270 std::fill(profile.username.begin(), profile.username.end(), '\0');
269 const auto username_std = new_username.toStdString(); 271 const auto username_std = new_username.toStdString();
270 if (username_std.size() > profile.username.size()) { 272 if (username_std.size() > profile.username.size()) {
271 std::copy_n(username_std.begin(), std::min(profile.username.size(), username_std.size()), 273 std::copy_n(username_std.begin(), std::min(profile.username.size(), username_std.size()),
@@ -280,7 +282,10 @@ void ConfigureSystem::RenameUser() {
280 user, 0, 282 user, 0,
281 new QStandardItem{ 283 new QStandardItem{
282 GetIcon(*uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), 284 GetIcon(*uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
283 QString::fromStdString(username_std + '\n' + uuid->FormatSwitch())}); 285 tr("%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. "
286 "00112233-4455-6677-8899-AABBCCDDEEFF))")
287 .arg(QString::fromStdString(username_std),
288 QString::fromStdString(uuid->FormatSwitch()))});
284 UpdateCurrentUser(); 289 UpdateCurrentUser();
285} 290}
286 291
@@ -290,9 +295,10 @@ void ConfigureSystem::DeleteUser() {
290 ASSERT(uuid != boost::none); 295 ASSERT(uuid != boost::none);
291 const auto username = GetAccountUsername(*uuid); 296 const auto username = GetAccountUsername(*uuid);
292 297
293 const auto confirm = QMessageBox::question( 298 const auto confirm =
294 this, tr("Confirm Delete"), 299 QMessageBox::question(this, tr("Confirm Delete"),
295 tr("You are about to delete user with name %1. Are you sure?").arg(username.c_str())); 300 tr("You are about to delete user with name %1. Are you sure?")
301 .arg(QString::fromStdString(username)));
296 302
297 if (confirm == QMessageBox::No) 303 if (confirm == QMessageBox::No)
298 return; 304 return;
diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h
index 6adadfccf..b73e0719c 100644
--- a/src/yuzu/configuration/configure_system.h
+++ b/src/yuzu/configuration/configure_system.h
@@ -8,7 +8,11 @@
8 8
9#include <QList> 9#include <QList>
10#include <QWidget> 10#include <QWidget>
11#include "core/hle/service/acc/profile_manager.h" 11
12namespace Service::Account {
13class ProfileManager;
14struct UUID;
15} // namespace Service::Account
12 16
13class QGraphicsScene; 17class QGraphicsScene;
14class QStandardItem; 18class QStandardItem;