From 82e9bcc55f601dea5f979f788bf5e0903e0d11f5 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 26 Oct 2024 15:54:04 +1000 Subject: [PATCH] Qt: Compatibility with Qt 6.7 Dunno why updating packages is taking so long... --- .github/workflows/rolling-release.yml | 185 +++++++++--------- CMakeModules/DuckStationDependencies.cmake | 4 +- .../flatpak/org.duckstation.DuckStation.yaml | 4 +- src/duckstation-qt/logwindow.cpp | 2 +- src/duckstation-qt/qthost.cpp | 16 +- src/duckstation-qt/qthost.h | 5 + 6 files changed, 117 insertions(+), 99 deletions(-) diff --git a/.github/workflows/rolling-release.yml b/.github/workflows/rolling-release.yml index c97c5546bb..e050de5dd0 100644 --- a/.github/workflows/rolling-release.yml +++ b/.github/workflows/rolling-release.yml @@ -455,95 +455,95 @@ jobs: name: "linux-x64-sse2-appimage" path: "DuckStation-x64-SSE2.AppImage" - # Disabled until KDE release the Qt 6.8 SDK - #linux-flatpak-build: - # name: Linux Flatpak Build - # runs-on: ubuntu-22.04 - # container: - # image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.7 - # options: --privileged - # timeout-minutes: 120 - # steps: - # - uses: actions/checkout@v4.1.6 - # with: - # fetch-depth: 0 - # set-safe-directory: ${{ env.GITHUB_WORKSPACE }} - # - # # Work around container ownership issue - # - name: Set Safe Directory - # shell: bash - # run: git config --global --add safe.directory "*" - # - # - name: Initialize Build Tag - # run: | - # echo '#pragma once' > src/scmversion/tag.h - # - # - name: Set Build Tags - # if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' - # run: | - # echo '#define SCM_RELEASE_TAGS {"latest", "preview"}' >> src/scmversion/tag.h - # - # - name: Tag as Preview Release - # if: github.ref == 'refs/heads/master' - # run: | - # echo '#define SCM_RELEASE_TAG "preview"' >> src/scmversion/tag.h - # - # - name: Tag as Rolling Release - # if: github.ref == 'refs/heads/dev' - # run: | - # echo '#define SCM_RELEASE_TAG "latest"' >> src/scmversion/tag.h - # - # - name: Download Patch Archives - # shell: bash - # run: | - # cd data/resources - # curl -LO "https://github.com/duckstation/chtdb/releases/download/latest/cheats.zip" - # curl -LO "https://github.com/duckstation/chtdb/releases/download/latest/patches.zip" - # - # - name: Generate AppStream XML - # run: | - # scripts/generate-metainfo.sh scripts/flatpak - # cat scripts/flatpak/org.duckstation.DuckStation.metainfo.xml - # - # - name: Validate AppStream XML - # run: flatpak-builder-lint appstream scripts/flatpak/org.duckstation.DuckStation.metainfo.xml - # - # - name: Validate Manifest - # run: flatpak-builder-lint manifest scripts/flatpak/org.duckstation.DuckStation.yaml - # - # - name: Build Flatpak - # uses: flathub-infra/flatpak-github-actions/flatpak-builder@23796715b3dfa4c86ddf50cf29c3cc8b3c82dca8 - # with: - # bundle: duckstation-x64.flatpak - # upload-artifact: false - # manifest-path: scripts/flatpak/org.duckstation.DuckStation.yaml - # arch: x86_64 - # build-bundle: true - # verbose: true - # mirror-screenshots-url: https://dl.flathub.org/media - # branch: stable - # cache: true - # restore-cache: true - # cache-key: flatpak-x64-${{ hashFiles('scripts/flatpak/**/*.yaml') }} - # - # - name: Validate Build - # run: | - # flatpak-builder-lint repo repo - # - # - name: Push To Flathub Stable - # if: github.ref == 'refs/heads/dev' - # uses: flathub-infra/flatpak-github-actions/flat-manager@b6c92176b7f578aedd80cac74cd8f0336f618e89 - # with: - # flat-manager-url: https://hub.flathub.org/ - # repository: stable - # token: ${{ secrets.FLATHUB_STABLE_TOKEN }} - # build-log-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - # - # - name: Upload Flatpak - # uses: actions/upload-artifact@v4.3.3 - # with: - # name: "linux-flatpak" - # path: "duckstation-x64.flatpak" + + linux-flatpak-build: + name: Linux Flatpak Build + runs-on: ubuntu-22.04 + container: + image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.7 + options: --privileged + timeout-minutes: 120 + steps: + - uses: actions/checkout@v4.1.6 + with: + fetch-depth: 0 + set-safe-directory: ${{ env.GITHUB_WORKSPACE }} + + # Work around container ownership issue + - name: Set Safe Directory + shell: bash + run: git config --global --add safe.directory "*" + + - name: Initialize Build Tag + run: | + echo '#pragma once' > src/scmversion/tag.h + + - name: Set Build Tags + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' + run: | + echo '#define SCM_RELEASE_TAGS {"latest", "preview"}' >> src/scmversion/tag.h + + - name: Tag as Preview Release + if: github.ref == 'refs/heads/master' + run: | + echo '#define SCM_RELEASE_TAG "preview"' >> src/scmversion/tag.h + + - name: Tag as Rolling Release + if: github.ref == 'refs/heads/dev' + run: | + echo '#define SCM_RELEASE_TAG "latest"' >> src/scmversion/tag.h + + - name: Download Patch Archives + shell: bash + run: | + cd data/resources + curl -LO "https://github.com/duckstation/chtdb/releases/download/latest/cheats.zip" + curl -LO "https://github.com/duckstation/chtdb/releases/download/latest/patches.zip" + + - name: Generate AppStream XML + run: | + scripts/generate-metainfo.sh scripts/flatpak + cat scripts/flatpak/org.duckstation.DuckStation.metainfo.xml + + - name: Validate AppStream XML + run: flatpak-builder-lint appstream scripts/flatpak/org.duckstation.DuckStation.metainfo.xml + + - name: Validate Manifest + run: flatpak-builder-lint manifest scripts/flatpak/org.duckstation.DuckStation.yaml + + - name: Build Flatpak + uses: flathub-infra/flatpak-github-actions/flatpak-builder@23796715b3dfa4c86ddf50cf29c3cc8b3c82dca8 + with: + bundle: duckstation-x64.flatpak + upload-artifact: false + manifest-path: scripts/flatpak/org.duckstation.DuckStation.yaml + arch: x86_64 + build-bundle: true + verbose: true + mirror-screenshots-url: https://dl.flathub.org/media + branch: stable + cache: true + restore-cache: true + cache-key: flatpak-x64-${{ hashFiles('scripts/flatpak/**/*.yaml') }} + + - name: Validate Build + run: | + flatpak-builder-lint repo repo + + - name: Push To Flathub Stable + if: github.ref == 'refs/heads/dev' + uses: flathub-infra/flatpak-github-actions/flat-manager@b6c92176b7f578aedd80cac74cd8f0336f618e89 + with: + flat-manager-url: https://hub.flathub.org/ + repository: stable + token: ${{ secrets.FLATHUB_STABLE_TOKEN }} + build-log-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + + - name: Upload Flatpak + uses: actions/upload-artifact@v4.3.3 + with: + name: "linux-flatpak" + path: "duckstation-x64.flatpak" macos-build: @@ -622,8 +622,7 @@ jobs: create-release: name: Create Release - #needs: [windows-x64-build, windows-x64-sse2-build, windows-arm64-build, linux-x64-appimage-build, linux-x64-sse2-appimage-build, linux-flatpak-build, macos-build] - needs: [windows-x64-build, windows-x64-sse2-build, windows-arm64-build, linux-x64-appimage-build, linux-x64-sse2-appimage-build, macos-build] + needs: [windows-x64-build, windows-x64-sse2-build, windows-arm64-build, linux-x64-appimage-build, linux-x64-sse2-appimage-build, linux-flatpak-build, macos-build] runs-on: ubuntu-22.04 if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' steps: @@ -652,7 +651,7 @@ jobs: ./artifacts/windows-arm64/duckstation-windows-arm64-release-symbols.zip ./artifacts/linux-x64-appimage/DuckStation-x64.AppImage ./artifacts/linux-x64-sse2-appimage/DuckStation-x64-SSE2.AppImage - #./artifacts/linux-flatpak/duckstation-x64.flatpak + ./artifacts/linux-flatpak/duckstation-x64.flatpak ./artifacts/macos/duckstation-mac-release.zip - name: Create Rolling Release @@ -672,6 +671,6 @@ jobs: ./artifacts/windows-arm64/duckstation-windows-arm64-release-symbols.zip ./artifacts/linux-x64-appimage/DuckStation-x64.AppImage ./artifacts/linux-x64-sse2-appimage/DuckStation-x64-SSE2.AppImage - #./artifacts/linux-flatpak/duckstation-x64.flatpak + ./artifacts/linux-flatpak/duckstation-x64.flatpak ./artifacts/macos/duckstation-mac-release.zip diff --git a/CMakeModules/DuckStationDependencies.cmake b/CMakeModules/DuckStationDependencies.cmake index f7e592bb0c..badeebf4bf 100644 --- a/CMakeModules/DuckStationDependencies.cmake +++ b/CMakeModules/DuckStationDependencies.cmake @@ -20,7 +20,7 @@ find_package(lunasvg 2.4.1 REQUIRED) find_package(cpuinfo REQUIRED) find_package(DiscordRPC 3.4.0 REQUIRED) find_package(SoundTouch 2.3.3 REQUIRED) -find_package(libzip 1.11.1 REQUIRED) +find_package(libzip 1.10.1 REQUIRED) if(NOT WIN32) find_package(CURL REQUIRED) @@ -40,7 +40,7 @@ if(ENABLE_WAYLAND) endif() if(BUILD_QT_FRONTEND) - find_package(Qt6 6.8.0 COMPONENTS Core Gui Widgets LinguistTools REQUIRED) + find_package(Qt6 6.7.0 COMPONENTS Core Gui Widgets LinguistTools REQUIRED) endif() find_package(Shaderc REQUIRED) diff --git a/scripts/flatpak/org.duckstation.DuckStation.yaml b/scripts/flatpak/org.duckstation.DuckStation.yaml index dc1369f03b..923e4ef32d 100644 --- a/scripts/flatpak/org.duckstation.DuckStation.yaml +++ b/scripts/flatpak/org.duckstation.DuckStation.yaml @@ -3,14 +3,14 @@ app-id: "org.duckstation.DuckStation" runtime: "org.kde.Platform" -runtime-version: "6.8" +runtime-version: "6.7" sdk: "org.kde.Sdk" sdk-extensions: - "org.freedesktop.Sdk.Extension.llvm17" add-extensions: "org.freedesktop.Platform.ffmpeg-full": directory: "lib/ffmpeg" - version: "24.08" + version: "23.08" add-ld-path: "." autodownload: true diff --git a/src/duckstation-qt/logwindow.cpp b/src/duckstation-qt/logwindow.cpp index 359cb5cd32..3d80c5f7ee 100644 --- a/src/duckstation-qt/logwindow.cpp +++ b/src/duckstation-qt/logwindow.cpp @@ -294,7 +294,7 @@ void LogWindow::logCallback(void* pUserParam, const char* channelName, const cha const QLatin1StringView qchannel((level <= Log::Level::Warning) ? functionName : channelName); - if (QThread::isMainThread()) + if (EmuThread::isMainThread()) { this_ptr->appendMessage(qchannel, static_cast(level), qmessage); } diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 3eeecb052a..50fd7eac3e 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -129,6 +129,20 @@ EmuThread::EmuThread(QThread* ui_thread) : QThread(), m_ui_thread(ui_thread) EmuThread::~EmuThread() = default; +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) + +bool EmuThread::isMainThread() +{ + return (QThread::currentThread() == g_emu_thread->m_ui_thread); +} + +bool EmuThread::isCurrentThread() const +{ + return QThread::currentThread() == this; +} + +#endif + void QtHost::RegisterTypes() { // Register any standard types we need elsewhere @@ -1741,7 +1755,7 @@ void EmuThread::queueAuxiliaryRenderWindowInputEvent(Host::AuxiliaryRenderWindow Host::AuxiliaryRenderWindowEventParam param2, Host::AuxiliaryRenderWindowEventParam param3) { - DebugAssert(QThread::isMainThread()); + DebugAssert(isMainThread()); QMetaObject::invokeMethod(this, "processAuxiliaryRenderWindowInputEvent", Qt::QueuedConnection, Q_ARG(void*, userdata), Q_ARG(quint32, static_cast(event)), Q_ARG(quint32, param1.uint_param), Q_ARG(quint32, param2.uint_param), diff --git a/src/duckstation-qt/qthost.h b/src/duckstation-qt/qthost.h index 8fccd971d5..2d96ab5bff 100644 --- a/src/duckstation-qt/qthost.h +++ b/src/duckstation-qt/qthost.h @@ -89,6 +89,11 @@ class EmuThread : public QThread static void start(); static void stop(); +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) + static bool isMainThread(); + bool isCurrentThread() const; +#endif + ALWAYS_INLINE QEventLoop* getEventLoop() const { return m_event_loop; } ALWAYS_INLINE bool isFullscreen() const { return m_is_fullscreen; }