Merge pull request #8327 from JosJuice/more-string-view-regression

DolphinQt: Fix whitelisting USB devices
This commit is contained in:
Connor McLaughlin 2019-08-23 21:32:13 +10:00 committed by GitHub
commit 88522b7a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,8 +4,6 @@
#include "DolphinQt/Settings/USBDeviceAddToWhitelistDialog.h" #include "DolphinQt/Settings/USBDeviceAddToWhitelistDialog.h"
#include <string_view>
#include <QButtonGroup> #include <QButtonGroup>
#include <QDialog> #include <QDialog>
#include <QDialogButtonBox> #include <QDialogButtonBox>
@ -29,7 +27,7 @@
#include "UICommon/USBUtils.h" #include "UICommon/USBUtils.h"
static bool IsValidUSBIDString(std::string_view string) static bool IsValidUSBIDString(const std::string& string)
{ {
if (string.empty() || string.length() > 4) if (string.empty() || string.length() > 4)
return false; return false;
@ -126,8 +124,8 @@ void USBDeviceAddToWhitelistDialog::RefreshDeviceList()
void USBDeviceAddToWhitelistDialog::AddUSBDeviceToWhitelist() void USBDeviceAddToWhitelistDialog::AddUSBDeviceToWhitelist()
{ {
const std::string_view vid_string = StripSpaces(device_vid_textbox->text().toStdString()); const std::string vid_string(StripSpaces(device_vid_textbox->text().toStdString()));
const std::string_view pid_string = StripSpaces(device_pid_textbox->text().toStdString()); const std::string pid_string(StripSpaces(device_pid_textbox->text().toStdString()));
if (!IsValidUSBIDString(vid_string)) if (!IsValidUSBIDString(vid_string))
{ {
// i18n: Here, VID means Vendor ID (for a USB device). // i18n: Here, VID means Vendor ID (for a USB device).
@ -153,8 +151,8 @@ void USBDeviceAddToWhitelistDialog::AddUSBDeviceToWhitelist()
return; return;
} }
const u16 vid = static_cast<u16>(std::stoul(std::string(vid_string), nullptr, 16)); const u16 vid = static_cast<u16>(std::stoul(vid_string, nullptr, 16));
const u16 pid = static_cast<u16>(std::stoul(std::string(pid_string), nullptr, 16)); const u16 pid = static_cast<u16>(std::stoul(pid_string, nullptr, 16));
if (SConfig::GetInstance().IsUSBDeviceWhitelisted({vid, pid})) if (SConfig::GetInstance().IsUSBDeviceWhitelisted({vid, pid}))
{ {