From 7cb2d3f143f120d7a2e9e73c22368c6d46ab84f8 Mon Sep 17 00:00:00 2001 From: oltolm Date: Mon, 24 Jul 2023 06:30:21 +0200 Subject: [PATCH] opengl: fix Qt warnings (#14249) --- rpcs3/rpcs3qt/gl_gs_frame.cpp | 12 ++++++++++-- rpcs3/util/vm_native.cpp | 8 ++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/rpcs3/rpcs3qt/gl_gs_frame.cpp b/rpcs3/rpcs3qt/gl_gs_frame.cpp index 549ab10449..671075cefc 100644 --- a/rpcs3/rpcs3qt/gl_gs_frame.cpp +++ b/rpcs3/rpcs3qt/gl_gs_frame.cpp @@ -1,5 +1,6 @@ #include "gl_gs_frame.h" +#include "Emu/System.h" #include "Emu/system_config.h" #include @@ -31,7 +32,11 @@ draw_context_t gl_gs_frame::make_context() { auto surface = new QOffscreenSurface(); surface->setFormat(m_format); - surface->create(); + // Workaround for the Qt warning: "Attempting to create QWindow-based QOffscreenSurface outside the gui thread. Expect failures." + Emu.BlockingCallFromMainThread([&]() + { + surface->create(); + }); // Share resources with the first created context context->handle->setShareContext(m_primary_context->handle); @@ -117,5 +122,8 @@ void gl_gs_frame::flip(draw_context_t context, bool skip_frame) const auto gl_ctx = static_cast(context); - gl_ctx->handle->swapBuffers(gl_ctx->surface); + if (auto window = dynamic_cast(gl_ctx->surface); window && window->isExposed()) + { + gl_ctx->handle->swapBuffers(gl_ctx->surface); + } } diff --git a/rpcs3/util/vm_native.cpp b/rpcs3/util/vm_native.cpp index 4056adf438..14bff5cdb4 100644 --- a/rpcs3/util/vm_native.cpp +++ b/rpcs3/util/vm_native.cpp @@ -52,7 +52,7 @@ namespace utils #ifdef MAP_NORESERVE constexpr int c_map_noreserve = MAP_NORESERVE; #else - constexpr int c_map_noreserve = 0; + [[maybe_unused]] constexpr int c_map_noreserve = 0; #endif #ifdef MADV_FREE @@ -66,7 +66,7 @@ namespace utils #ifdef MADV_HUGEPAGE constexpr int c_madv_hugepage = MADV_HUGEPAGE; #else - constexpr int c_madv_hugepage = 0; + [[maybe_unused]] constexpr int c_madv_hugepage = 0; #endif #if defined(MADV_DONTDUMP) && defined(MADV_DODUMP) @@ -76,8 +76,8 @@ namespace utils constexpr int c_madv_no_dump = MADV_NOCORE; constexpr int c_madv_dump = MADV_CORE; #else - constexpr int c_madv_no_dump = 0; - constexpr int c_madv_dump = 0; + [[maybe_unused]] constexpr int c_madv_no_dump = 0; + [[maybe_unused]] constexpr int c_madv_dump = 0; #endif #if defined(MFD_HUGETLB) && defined(MFD_HUGE_2MB)