mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
game_list: Use QString::fromStdString() where applicable instead of c_str()
The codec used by Qt for const char* and std::string don't necessarily have to be the same depending on locale. Therefore, we should be using the correct functions to do the conversions.
This commit is contained in:
parent
1ac45342dd
commit
a5ac53dd4c
1 changed files with 7 additions and 5 deletions
|
@ -368,21 +368,23 @@ void GameList::LoadInterfaceLayout() {
|
||||||
const QStringList GameList::supported_file_extensions = {"nso", "nro", "nca", "xci"};
|
const QStringList GameList::supported_file_extensions = {"nso", "nro", "nca", "xci"};
|
||||||
|
|
||||||
static bool HasSupportedFileExtension(const std::string& file_name) {
|
static bool HasSupportedFileExtension(const std::string& file_name) {
|
||||||
QFileInfo file = QFileInfo(file_name.c_str());
|
const QFileInfo file = QFileInfo(QString::fromStdString(file_name));
|
||||||
return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive);
|
return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsExtractedNCAMain(const std::string& file_name) {
|
static bool IsExtractedNCAMain(const std::string& file_name) {
|
||||||
return QFileInfo(file_name.c_str()).fileName() == "main";
|
return QFileInfo(QString::fromStdString(file_name)).fileName() == "main";
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString FormatGameName(const std::string& physical_name) {
|
static QString FormatGameName(const std::string& physical_name) {
|
||||||
QFileInfo file_info(physical_name.c_str());
|
const QString physical_name_as_qstring = QString::fromStdString(physical_name);
|
||||||
|
const QFileInfo file_info(physical_name_as_qstring);
|
||||||
|
|
||||||
if (IsExtractedNCAMain(physical_name)) {
|
if (IsExtractedNCAMain(physical_name)) {
|
||||||
return file_info.dir().path();
|
return file_info.dir().path();
|
||||||
} else {
|
|
||||||
return QString::fromStdString(physical_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return physical_name_as_qstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::RefreshGameDirectory() {
|
void GameList::RefreshGameDirectory() {
|
||||||
|
|
Loading…
Reference in a new issue