From 4e6b37ca04479a296d8bbee56446920adc5e5fdd Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 30 Oct 2021 19:48:52 +0200 Subject: [PATCH] Qt: fix missing vfs mount --- rpcs3/rpcs3qt/screenshot_manager_dialog.cpp | 12 +++++++++ rpcs3/rpcs3qt/trophy_manager_dialog.cpp | 29 +++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/rpcs3/rpcs3qt/screenshot_manager_dialog.cpp b/rpcs3/rpcs3qt/screenshot_manager_dialog.cpp index b7f8319848..92645bb3ae 100644 --- a/rpcs3/rpcs3qt/screenshot_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/screenshot_manager_dialog.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "screenshot_manager_dialog.h" #include "screenshot_preview.h" #include "qt_utils.h" @@ -14,6 +15,8 @@ #include #include +LOG_CHANNEL(gui_log, "GUI"); + screenshot_manager_dialog::screenshot_manager_dialog(QWidget* parent) : QDialog(parent) { setWindowTitle(tr("Screenshots")); @@ -28,6 +31,9 @@ screenshot_manager_dialog::screenshot_manager_dialog(QWidget* parent) : QDialog( m_grid->setIconSize(m_icon_size); m_grid->setGridSize(m_icon_size + QSize(10, 10)); + // Make sure the directory is mounted + vfs::mount("/dev_hdd0", rpcs3::utils::get_hdd0_dir()); + const std::string screenshot_path_qt = fs::get_config_dir() + "screenshots/"; const std::string screenshot_path_cell = vfs::get("/dev_hdd0/photo/"); const QStringList filter{ QStringLiteral("*.png") }; @@ -38,6 +44,12 @@ screenshot_manager_dialog::screenshot_manager_dialog(QWidget* parent) : QDialog( for (const std::string& path : { screenshot_path_qt, screenshot_path_cell }) { + if (path.empty()) + { + gui_log.error("Screenshot manager: Trying to load screenshots from empty path!"); + continue; + } + QDirIterator dir_iter(QString::fromStdString(path), filter, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); while (dir_iter.hasNext()) diff --git a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp index a6d89b59ce..819de0efdd 100644 --- a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp @@ -60,6 +60,9 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr gui_s m_show_gold_trophies = m_gui_settings->GetValue(gui::tr_show_gold).toBool(); m_show_platinum_trophies = m_gui_settings->GetValue(gui::tr_show_platinum).toBool(); + // Make sure the directory is mounted + vfs::mount("/dev_hdd0", rpcs3::utils::get_hdd0_dir()); + // Get the currently selected user's trophy path. m_trophy_dir = "/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/"; @@ -346,15 +349,22 @@ trophy_manager_dialog::~trophy_manager_dialog() bool trophy_manager_dialog::LoadTrophyFolderToDB(const std::string& trop_name) { - const std::string trophyPath = m_trophy_dir + trop_name; + const std::string trophy_path = m_trophy_dir + trop_name; + const std::string vfs_path = vfs::get(trophy_path + "/"); + + if (vfs_path.empty()) + { + gui_log.error("Failed to load trophy database for %s. Path empty!", trop_name); + return false; + } // Populate GameTrophiesData std::unique_ptr game_trophy_data = std::make_unique(); - game_trophy_data->path = vfs::get(trophyPath + "/"); + game_trophy_data->path = vfs_path; game_trophy_data->trop_usr.reset(new TROPUSRLoader()); - const std::string tropusr_path = trophyPath + "/TROPUSR.DAT"; - const std::string tropconf_path = trophyPath + "/TROPCONF.SFM"; + const std::string tropusr_path = trophy_path + "/TROPUSR.DAT"; + const std::string tropconf_path = trophy_path + "/TROPCONF.SFM"; const bool success = game_trophy_data->trop_usr->Load(tropusr_path, tropconf_path).success; fs::file config(vfs::get(tropconf_path)); @@ -671,7 +681,16 @@ void trophy_manager_dialog::StartTrophyLoadThreads() { m_trophies_db.clear(); - const QDir trophy_dir(qstr(vfs::get(m_trophy_dir))); + const QString trophy_path = qstr(vfs::get(m_trophy_dir)); + + if (trophy_path.isEmpty()) + { + gui_log.error("Cannot load trophy dir. Path empty!"); + RepaintUI(true); + return; + } + + const QDir trophy_dir(trophy_path); const auto folder_list = trophy_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); const int count = folder_list.count();