diff options
Diffstat (limited to 'src/yuzu')
-rw-r--r-- | src/yuzu/game_list.cpp | 5 | ||||
-rw-r--r-- | src/yuzu/game_list_worker.cpp | 7 | ||||
-rw-r--r-- | src/yuzu/game_list_worker.h | 5 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 68 |
4 files changed, 49 insertions, 36 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 74f48031a..2bb1a0239 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -826,12 +826,13 @@ void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) { tree_view->setColumnHidden(COLUMN_SIZE, !UISettings::values.show_size); tree_view->setColumnHidden(COLUMN_PLAY_TIME, !UISettings::values.show_play_time); + // Before deleting rows, cancel the worker so that it is not using them + emit ShouldCancelWorker(); + // Delete any rows that might already exist if we're repopulating item_model->removeRows(0, item_model->rowCount()); search_field->clear(); - emit ShouldCancelWorker(); - GameListWorker* worker = new GameListWorker(vfs, provider, game_dirs, compatibility_list, play_time_manager, system); diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 588f1dd6e..077ced12b 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -293,7 +293,7 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) { void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan, GameListDir* parent_dir) { const auto callback = [this, target, parent_dir](const std::filesystem::path& path) -> bool { - if (stop_processing) { + if (stop_requested) { // Breaks the callback loop. return false; } @@ -399,7 +399,6 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa } void GameListWorker::run() { - stop_processing = false; provider->ClearAllEntries(); for (UISettings::GameDir& game_dir : game_dirs) { @@ -427,9 +426,11 @@ void GameListWorker::run() { } emit Finished(watch_list); + processing_completed.Set(); } void GameListWorker::Cancel() { this->disconnect(); - stop_processing = true; + stop_requested.store(true); + processing_completed.Wait(); } diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h index 2bb0a0cb6..54dc05e30 100644 --- a/src/yuzu/game_list_worker.h +++ b/src/yuzu/game_list_worker.h @@ -12,6 +12,7 @@ #include <QRunnable> #include <QString> +#include "common/thread.h" #include "yuzu/compatibility_list.h" #include "yuzu/play_time_manager.h" @@ -82,7 +83,9 @@ private: const PlayTime::PlayTimeManager& play_time_manager; QStringList watch_list; - std::atomic_bool stop_processing; + + Common::Event processing_completed; + std::atomic_bool stop_requested = false; Core::System& system; }; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 425f546f7..1431cf2fe 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -67,6 +67,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #define QT_NO_OPENGL #include <QClipboard> #include <QDesktopServices> +#include <QDir> #include <QFile> #include <QFileDialog> #include <QInputDialog> @@ -76,6 +77,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include <QPushButton> #include <QScreen> #include <QShortcut> +#include <QStandardPaths> #include <QStatusBar> #include <QString> #include <QSysInfo> @@ -2868,44 +2870,50 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga #endif // __linux__ std::filesystem::path target_directory{}; - // Determine target directory for shortcut -#if defined(WIN32) - const char* home = std::getenv("USERPROFILE"); -#else - const char* home = std::getenv("HOME"); -#endif - const std::filesystem::path home_path = (home == nullptr ? "~" : home); - const char* xdg_data_home = std::getenv("XDG_DATA_HOME"); - if (target == GameListShortcutTarget::Desktop) { - target_directory = home_path / "Desktop"; - if (!Common::FS::IsDir(target_directory)) { - QMessageBox::critical( - this, tr("Create Shortcut"), - tr("Cannot create shortcut on desktop. Path \"%1\" does not exist.") - .arg(QString::fromStdString(target_directory.generic_string())), - QMessageBox::StandardButton::Ok); - return; - } - } else if (target == GameListShortcutTarget::Applications) { - target_directory = (xdg_data_home == nullptr ? home_path / ".local/share" : xdg_data_home) / - "applications"; - if (!Common::FS::CreateDirs(target_directory)) { - QMessageBox::critical( - this, tr("Create Shortcut"), - tr("Cannot create shortcut in applications menu. Path \"%1\" " - "does not exist and cannot be created.") - .arg(QString::fromStdString(target_directory.generic_string())), - QMessageBox::StandardButton::Ok); - return; + switch (target) { + case GameListShortcutTarget::Desktop: { + const QString desktop_path = + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + target_directory = desktop_path.toUtf8().toStdString(); + break; + } + case GameListShortcutTarget::Applications: { + const QString applications_path = + QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation); + if (applications_path.isEmpty()) { + const char* home = std::getenv("HOME"); + if (home != nullptr) { + target_directory = std::filesystem::path(home) / ".local/share/applications"; + } + } else { + target_directory = applications_path.toUtf8().toStdString(); } + break; + } + default: + return; + } + + const QDir dir(QString::fromStdString(target_directory.generic_string())); + if (!dir.exists()) { + QMessageBox::critical(this, tr("Create Shortcut"), + tr("Cannot create shortcut. Path \"%1\" does not exist.") + .arg(QString::fromStdString(target_directory.generic_string())), + QMessageBox::StandardButton::Ok); + return; } const std::string game_file_name = std::filesystem::path(game_path).filename().string(); // Determine full paths for icon and shortcut #if defined(__linux__) || defined(__FreeBSD__) + const char* home = std::getenv("HOME"); + const std::filesystem::path home_path = (home == nullptr ? "~" : home); + const char* xdg_data_home = std::getenv("XDG_DATA_HOME"); + std::filesystem::path system_icons_path = - (xdg_data_home == nullptr ? home_path / ".local/share/" : xdg_data_home) / + (xdg_data_home == nullptr ? home_path / ".local/share/" + : std::filesystem::path(xdg_data_home)) / "icons/hicolor/256x256"; if (!Common::FS::CreateDirs(system_icons_path)) { QMessageBox::critical( |