From cf9cc4147845810dd2af387e2ef3a8559f832722 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 24 May 2019 20:56:58 -0400 Subject: yuzu/applets/software_keyboard: Specify string conversions explicitly Allows the software keyboard applet code to compile with implicit string conversions disabled. --- src/yuzu/applets/software_keyboard.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/yuzu/applets/software_keyboard.cpp') diff --git a/src/yuzu/applets/software_keyboard.cpp b/src/yuzu/applets/software_keyboard.cpp index f3eb29b25..4f13e1d75 100644 --- a/src/yuzu/applets/software_keyboard.cpp +++ b/src/yuzu/applets/software_keyboard.cpp @@ -18,23 +18,30 @@ QtSoftwareKeyboardValidator::QtSoftwareKeyboardValidator( : parameters(std::move(parameters)) {} QValidator::State QtSoftwareKeyboardValidator::validate(QString& input, int& pos) const { - if (input.size() > parameters.max_length) + if (input.size() > parameters.max_length) { return Invalid; - if (parameters.disable_space && input.contains(' ')) + } + if (parameters.disable_space && input.contains(QLatin1Char{' '})) { return Invalid; - if (parameters.disable_address && input.contains('@')) + } + if (parameters.disable_address && input.contains(QLatin1Char{'@'})) { return Invalid; - if (parameters.disable_percent && input.contains('%')) + } + if (parameters.disable_percent && input.contains(QLatin1Char{'%'})) { return Invalid; - if (parameters.disable_slash && (input.contains('/') || input.contains('\\'))) + } + if (parameters.disable_slash && + (input.contains(QLatin1Char{'/'}) || input.contains(QLatin1Char{'\\'}))) { return Invalid; + } if (parameters.disable_number && std::any_of(input.begin(), input.end(), [](QChar c) { return c.isDigit(); })) { return Invalid; } - if (parameters.disable_download_code && - std::any_of(input.begin(), input.end(), [](QChar c) { return c == 'O' || c == 'I'; })) { + if (parameters.disable_download_code && std::any_of(input.begin(), input.end(), [](QChar c) { + return c == QLatin1Char{'O'} || c == QLatin1Char{'I'}; + })) { return Invalid; } -- cgit v1.2.3 From b3d7180164157c64b48ed5ae549d1d02ef92e092 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 24 May 2019 21:00:26 -0400 Subject: yuzu/applets/software_keyboard: Resolve sign mismatch comparison Qt uses a signed value to represent container sizes, so this was causing a sign mismatch warning. --- src/yuzu/applets/software_keyboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/yuzu/applets/software_keyboard.cpp') diff --git a/src/yuzu/applets/software_keyboard.cpp b/src/yuzu/applets/software_keyboard.cpp index 4f13e1d75..7c95d730b 100644 --- a/src/yuzu/applets/software_keyboard.cpp +++ b/src/yuzu/applets/software_keyboard.cpp @@ -18,7 +18,7 @@ QtSoftwareKeyboardValidator::QtSoftwareKeyboardValidator( : parameters(std::move(parameters)) {} QValidator::State QtSoftwareKeyboardValidator::validate(QString& input, int& pos) const { - if (input.size() > parameters.max_length) { + if (input.size() > static_cast(parameters.max_length)) { return Invalid; } if (parameters.disable_space && input.contains(QLatin1Char{' '})) { -- cgit v1.2.3 From 16bf7919396cff4952e191368fa0907897b81348 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 24 May 2019 21:01:46 -0400 Subject: yuzu/applets/software_keyboard: std::move argument in MainWindowFinishedText() Given the std::optional can contain an object type that heap allocates, we can use std::move to avoid an unnecessary copy/allocation from occurring. --- src/yuzu/applets/software_keyboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/yuzu/applets/software_keyboard.cpp') diff --git a/src/yuzu/applets/software_keyboard.cpp b/src/yuzu/applets/software_keyboard.cpp index 7c95d730b..5223ec977 100644 --- a/src/yuzu/applets/software_keyboard.cpp +++ b/src/yuzu/applets/software_keyboard.cpp @@ -149,7 +149,7 @@ void QtSoftwareKeyboard::SendTextCheckDialog(std::u16string error_message, void QtSoftwareKeyboard::MainWindowFinishedText(std::optional text) { // Acquire the HLE mutex std::lock_guard lock{HLE::g_hle_lock}; - text_output(text); + text_output(std::move(text)); } void QtSoftwareKeyboard::MainWindowFinishedCheckDialog() { -- cgit v1.2.3