From 6dd526cda0d7b813fe2e361a609d5299cb4b315c Mon Sep 17 00:00:00 2001 From: crueter Date: Sun, 1 Feb 2026 13:57:30 -0500 Subject: [PATCH] Fix build Signed-off-by: crueter --- src/android/app/src/main/jni/native.cpp | 40 +-------------------- src/frontend_common/update_checker.cpp | 46 +++++++++++++++++++++++-- src/frontend_common/update_checker.h | 1 + src/yuzu/main_window.cpp | 46 ++++--------------------- src/yuzu/main_window.h | 4 +-- 5 files changed, 54 insertions(+), 83 deletions(-) diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 27eee78f01..37f195fe15 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -4,7 +4,6 @@ // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#define ENABLE_UPDATE_CHECKER 1 #define VMA_IMPLEMENTATION #include "video_core/vulkan_common/vma.h" @@ -1618,48 +1617,11 @@ JNIEXPORT jboolean JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_isNightlyBuild( #ifdef ENABLE_UPDATE_CHECKER -std::optional checkForUpdate() { - const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != NULL) || - (strstr(Common::g_build_version, "alpha") != NULL) || - (strstr(Common::g_build_version, "beta") != NULL) || - (strstr(Common::g_build_version, "rc") != NULL)); - const std::optional latest_release_tag = - UpdateChecker::GetLatestRelease(is_prerelease); - - if (!latest_release_tag) - goto empty; - - { - std::string tag, build; - if (Common::g_is_nightly_build) { - std::vector result; - - boost::split(result, latest_release_tag->tag, boost::is_any_of(".")); - if (result.size() != 2) - goto empty; - tag = result[1]; - - boost::split(result, std::string{Common::g_build_version}, boost::is_any_of("-")); - if (result.empty()) - goto empty; - build = result[0]; - } else { - tag = latest_release_tag->tag; - build = Common::g_build_version; - } - - if (tag != build) - return latest_release_tag.value(); - } - - empty: - return std::nullopt; -} JNIEXPORT jobjectArray JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_checkForUpdate( JNIEnv* env, jobject obj) { - std::optional release = checkForUpdate(); + std::optional release = UpdateChecker::GetUpdate(); if (!release) return nullptr; const std::string tag = release->tag; diff --git a/src/frontend_common/update_checker.cpp b/src/frontend_common/update_checker.cpp index 53f3ca942d..1d7c8a4492 100644 --- a/src/frontend_common/update_checker.cpp +++ b/src/frontend_common/update_checker.cpp @@ -5,10 +5,13 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "update_checker.h" +#include +#include + +#include #include "common/logging/log.h" #include "common/scm_rev.h" -#include +#include "update_checker.h" #include @@ -137,3 +140,42 @@ std::optional UpdateChecker::GetLatestRelease(bool includ return {}; } } + +std::optional UpdateChecker::GetUpdate() { + const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != NULL) || + (strstr(Common::g_build_version, "alpha") != NULL) || + (strstr(Common::g_build_version, "beta") != NULL) || + (strstr(Common::g_build_version, "rc") != NULL)); + const std::optional latest_release_tag = + UpdateChecker::GetLatestRelease(is_prerelease); + + if (!latest_release_tag) + goto empty; + + { + std::string tag, build; + if (Common::g_is_nightly_build) { + std::vector result; + + boost::split(result, latest_release_tag->tag, boost::is_any_of(".")); + if (result.size() != 2) + goto empty; + tag = result[1]; + + boost::split(result, std::string{Common::g_build_version}, boost::is_any_of("-")); + if (result.empty()) + goto empty; + build = result[0]; + } else { + tag = latest_release_tag->tag; + build = Common::g_build_version; + } + + if (tag != build) + return latest_release_tag.value(); + } + +empty: + return UpdateChecker::Update{}; + +} diff --git a/src/frontend_common/update_checker.h b/src/frontend_common/update_checker.h index 9dbb321eef..fb6c25c3f3 100644 --- a/src/frontend_common/update_checker.h +++ b/src/frontend_common/update_checker.h @@ -19,4 +19,5 @@ typedef struct { std::optional GetResponse(std::string url, std::string path); std::optional GetLatestRelease(bool include_prereleases); +std::optional GetUpdate(); } // namespace UpdateChecker diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index 5ab7f0321e..d50dcad994 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -517,42 +517,8 @@ MainWindow::MainWindow(bool has_broken_vulkan) #ifdef ENABLE_UPDATE_CHECKER if (UISettings::values.check_for_updates) { - update_future = QtConcurrent::run([]() -> UpdateChecker::Update { - const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != NULL) || - (strstr(Common::g_build_version, "alpha") != NULL) || - (strstr(Common::g_build_version, "beta") != NULL) || - (strstr(Common::g_build_version, "rc") != NULL)); - const std::optional latest_release_tag = - UpdateChecker::GetLatestRelease(is_prerelease); - - if (!latest_release_tag) - goto empty; - - { - std::string tag, build; - if (Common::g_is_nightly_build) { - std::vector result; - - boost::split(result, latest_release_tag->tag, boost::is_any_of(".")); - if (result.size() != 2) - goto empty; - tag = result[1]; - - boost::split(result, std::string{Common::g_build_version}, boost::is_any_of("-")); - if (result.empty()) - goto empty; - build = result[0]; - } else { - tag = latest_release_tag->tag; - build = Common::g_build_version; - } - - if (tag != build) - return latest_release_tag.value(); - } - - empty: - return UpdateChecker::Update{}; + update_future = QtConcurrent::run([]() -> std::optional { + return UpdateChecker::GetUpdate(); }); update_watcher.connect(&update_watcher, &QFutureWatcher::finished, this, &MainWindow::OnEmulatorUpdateAvailable); @@ -4046,8 +4012,8 @@ void MainWindow::OnCaptureScreenshot() { #ifdef ENABLE_UPDATE_CHECKER void MainWindow::OnEmulatorUpdateAvailable() { - UpdateChecker::Update version = update_future.result(); - if (version.tag.empty()) + std::optional version = update_future.result(); + if (!version) return; QMessageBox update_prompt(this); @@ -4056,14 +4022,14 @@ void MainWindow::OnEmulatorUpdateAvailable() { update_prompt.addButton(QMessageBox::Yes); update_prompt.addButton(QMessageBox::Ignore); update_prompt.setText( - tr("Download %1?").arg(QString::fromStdString(version.name))); + tr("Download %1?").arg(QString::fromStdString(version->name))); update_prompt.exec(); if (update_prompt.button(QMessageBox::Yes) == update_prompt.clickedButton()) { auto const full_url = fmt::format("{}/{}/releases/tag/", std::string{Common::g_build_auto_update_website}, std::string{Common::g_build_auto_update_repo} ); - QDesktopServices::openUrl(QUrl(QString::fromStdString(full_url + version.tag))); + QDesktopServices::openUrl(QUrl(QString::fromStdString(full_url + version->tag))); } } #endif diff --git a/src/yuzu/main_window.h b/src/yuzu/main_window.h index 351a581729..41c2f4fea0 100644 --- a/src/yuzu/main_window.h +++ b/src/yuzu/main_window.h @@ -472,8 +472,8 @@ private: std::shared_ptr input_subsystem; #ifdef ENABLE_UPDATE_CHECKER - QFuture update_future; - QFutureWatcher update_watcher; + QFuture> update_future; + QFutureWatcher> update_watcher; #endif MultiplayerState* multiplayer_state = nullptr;