From b429993e08e7e4447fd76a7a793d984550160a40 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 29 May 2026 18:39:31 +1000 Subject: [PATCH] Qt: Move most recent migration to updater Saves checking on every startup. --- src/duckstation-qt/qthost.cpp | 28 ---------------------------- src/updater/updater.cpp | 21 +++++++++++++++++++++ src/updater/updater.h | 1 + src/updater/win32_main.cpp | 1 + 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 48919f895..d772c16b3 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -935,34 +935,6 @@ void QtHost::ApplyMigrations() } } } - -#ifdef _WIN32 -#ifdef _DEBUG -#define SUFFIX "d" -#else -#define SUFFIX -#endif - // Remove Qt6Svg.dll and the plugins which use QtSvg, since the updater can't remove them itself... - for (const char* path_to_remove : { - "Qt6Svg" SUFFIX ".dll", - "QtPlugins\\iconengines\\qsvgicon" SUFFIX ".dll", - "QtPlugins\\imageformats\\qsvg" SUFFIX ".dll", - }) - { - const std::string full_path = Path::Combine(EmuFolders::AppRoot, path_to_remove); - if (FileSystem::FileExists(full_path.c_str())) - { - Error error; - if (!FileSystem::DeleteFile(full_path.c_str(), &error)) - { - QMessageBox::critical(nullptr, "Error"_L1, - QString::fromStdString(fmt::format("Failed to delete conflicting library {}: {}", - path_to_remove, error.GetDescription()))); - } - } - } -#undef SUFFIX -#endif } void CoreThread::applySettings(bool display_osd_messages /* = false */) diff --git a/src/updater/updater.cpp b/src/updater/updater.cpp index 3f1d0435b..81e09563e 100644 --- a/src/updater/updater.cpp +++ b/src/updater/updater.cpp @@ -450,6 +450,27 @@ void Updater::CleanupStagingDirectory() m_progress->FormatError("Failed to remove staging directory '{}'", m_staging_directory); } +void Updater::CleanupStaleFiles() +{ +#ifdef _WIN32 + // Remove Qt6Svg.dll and the plugins which use QtSvg, since the staging/extraction won't remove it... + for (const char* path_to_remove : { + "Qt6Svg.dll", + "QtPlugins\\iconengines\\qsvgicon.dll", + "QtPlugins\\imageformats\\qsvg.dll", + }) + { + const std::string path = Path::Combine(m_destination_directory, path_to_remove); + if (!FileSystem::FileExists(path.c_str())) + continue; + + Error error; + if (!FileSystem::DeleteFile(path.c_str(), &error)) + m_progress->FormatModalError("Failed to remove file '{}': {}", path, error.GetDescription()); + } +#endif +} + bool Updater::ClearDestinationDirectory() { return RecursiveDeleteDirectory(m_destination_directory.c_str(), false); diff --git a/src/updater/updater.h b/src/updater/updater.h index de0f12688..f6c80b9a0 100644 --- a/src/updater/updater.h +++ b/src/updater/updater.h @@ -24,6 +24,7 @@ public: bool StageUpdate(); bool CommitUpdate(); void CleanupStagingDirectory(); + void CleanupStaleFiles(); bool ClearDestinationDirectory(); private: diff --git a/src/updater/win32_main.cpp b/src/updater/win32_main.cpp index e4a8c8907..0c96b3dcc 100644 --- a/src/updater/win32_main.cpp +++ b/src/updater/win32_main.cpp @@ -102,6 +102,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi updater.CleanupStagingDirectory(); updater.RemoveUpdateZip(); + updater.CleanupStaleFiles(); progress.FormatInformation("Launching '{}'...", StringUtil::WideStringToUTF8String(program_to_launch)); ShellExecuteW(nullptr, L"open", program_to_launch.c_str(), L"-updatecleanup", nullptr, SW_SHOWNORMAL);