VERY experimental Nintendo Switch 2 emulator
C++
game_list: Remove global instances of Core::System
lat9nqb6387b3e2ffc
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cppindex f9d949e75f..99c91a6a82 100644--- a/src/yuzu/game_list.cpp+++ b/src/yuzu/game_list.cpp@@ -305,8 +305,8 @@ void GameList::OnFilterCloseClicked() {}GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvider* provider,- GMainWindow* parent)- : QWidget{parent}, vfs(std::move(vfs)), provider(provider) {+ Core::System& system_, GMainWindow* parent)+ : QWidget{parent}, vfs(std::move(vfs)), provider(provider), system{system_} {watcher = new QFileSystemWatcher(this);connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory);@@ -738,7 +738,8 @@ void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {emit ShouldCancelWorker();- GameListWorker* worker = new GameListWorker(vfs, provider, game_dirs, compatibility_list);+ GameListWorker* worker =+ new GameListWorker(vfs, provider, game_dirs, compatibility_list, system);connect(worker, &GameListWorker::EntryReady, this, &GameList::AddEntry, Qt::QueuedConnection);connect(worker, &GameListWorker::DirEntryReady, this, &GameList::AddDirEntry,diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.hindex 10339dcca2..675469e669 100644--- a/src/yuzu/game_list.h+++ b/src/yuzu/game_list.h@@ -72,7 +72,8 @@ public:};explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs,- FileSys::ManualContentProvider* provider, GMainWindow* parent = nullptr);+ FileSys::ManualContentProvider* provider, Core::System& system_,+ GMainWindow* parent = nullptr);~GameList() override;QString GetLastFilterResultItem() const;@@ -145,6 +146,8 @@ private:CompatibilityList compatibility_list;friend class GameListSearchField;++ Core::System& system;};class GameListPlaceholder : public QWidget {diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cppindex 2d5492157b..fd92b36df7 100644--- a/src/yuzu/game_list_worker.cpp+++ b/src/yuzu/game_list_worker.cpp@@ -228,16 +228,15 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::striGameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs,FileSys::ManualContentProvider* provider,QVector<UISettings::GameDir>& game_dirs,- const CompatibilityList& compatibility_list)+ const CompatibilityList& compatibility_list, Core::System& system_): vfs(std::move(vfs)), provider(provider), game_dirs(game_dirs),- compatibility_list(compatibility_list) {}+ compatibility_list(compatibility_list), system{system_} {}GameListWorker::~GameListWorker() = default;void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {using namespace FileSys;- auto& system = Core::System::GetInstance();const auto& cache = dynamic_cast<ContentProviderUnion&>(system.GetContentProvider());auto installed_games = cache.ListEntriesFilterOrigin(std::nullopt, TitleType::Application,@@ -285,10 +284,7 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,GameListDir* parent_dir) {- auto& system = Core::System::GetInstance();-- const auto callback = [this, target, parent_dir,- &system](const std::filesystem::path& path) -> bool {+ const auto callback = [this, target, parent_dir](const std::filesystem::path& path) -> bool {if (stop_processing) {// Breaks the callback loop.return false;diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.hindex 396bb2623e..1383e9fbcf 100644--- a/src/yuzu/game_list_worker.h+++ b/src/yuzu/game_list_worker.h@@ -19,6 +19,10 @@#include "common/common_types.h"#include "yuzu/compatibility_list.h"+namespace Core {+class System;+}+class QStandardItem;namespace FileSys {@@ -37,7 +41,7 @@ public:explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs,FileSys::ManualContentProvider* provider,QVector<UISettings::GameDir>& game_dirs,- const CompatibilityList& compatibility_list);+ const CompatibilityList& compatibility_list, Core::System& system_);~GameListWorker() override;/// Starts the processing of directory tree information.@@ -80,4 +84,6 @@ private:QStringList watch_list;std::atomic_bool stop_processing;++ Core::System& system;};diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cppindex 056f7da36e..1d9e0f79d8 100644--- a/src/yuzu/main.cpp+++ b/src/yuzu/main.cpp@@ -701,7 +701,7 @@ void GMainWindow::InitializeWidgets() {render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, system);render_window->hide();- game_list = new GameList(vfs, provider.get(), this);+ game_list = new GameList(vfs, provider.get(), system, this);ui.horizontalLayout->addWidget(game_list);game_list_placeholder = new GameListPlaceholder(this);