From 265e875e5b35ddd36ac669556d57fac82de52635 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 10 Aug 2018 09:45:48 +0800 Subject: [PATCH] qt/main: Better file-existence checking within OnMenuRecentFile() and UpdateUITheme() --- src/citra_qt/main.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 3c6ff42d6..9670e63ad 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -1030,9 +1030,8 @@ void GMainWindow::OnMenuRecentFile() { QAction* action = qobject_cast(sender()); assert(action); - QString filename = action->data().toString(); - QFileInfo file_info(filename); - if (file_info.exists()) { + const QString filename = action->data().toString(); + if (QFileInfo::exists(filename)) { BootGame(filename); } else { // Display an error message and remove the file from the list. @@ -1402,15 +1401,14 @@ void GMainWindow::UpdateUITheme() { QStringList theme_paths(default_theme_paths); if (UISettings::values.theme != UISettings::themes[0].second && !UISettings::values.theme.isEmpty()) { - QString theme_uri(":" + UISettings::values.theme + "/style.qss"); + const QString theme_uri(":" + UISettings::values.theme + "/style.qss"); QFile f(theme_uri); - if (!f.exists()) { - LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found"); - } else { - f.open(QFile::ReadOnly | QFile::Text); + if (f.open(QFile::ReadOnly | QFile::Text)) { QTextStream ts(&f); qApp->setStyleSheet(ts.readAll()); GMainWindow::setStyleSheet(ts.readAll()); + } else { + LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found"); } theme_paths.append(QStringList{":/icons/default", ":/icons/" + UISettings::values.theme}); QIcon::setThemeName(":/icons/" + UISettings::values.theme);