From b7db2510efb44fa9eac5cd353e294b30b9dbdfff Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Mon, 6 Mar 2023 00:05:12 +1300 Subject: [PATCH 1/2] Don't discard ConfigChanged callback handle --- Source/Core/VideoCommon/AbstractGfx.cpp | 3 ++- Source/Core/VideoCommon/AbstractGfx.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/AbstractGfx.cpp b/Source/Core/VideoCommon/AbstractGfx.cpp index 6e1c56aa20..7c0cc10355 100644 --- a/Source/Core/VideoCommon/AbstractGfx.cpp +++ b/Source/Core/VideoCommon/AbstractGfx.cpp @@ -18,7 +18,8 @@ std::unique_ptr g_gfx; AbstractGfx::AbstractGfx() { - ConfigChangedEvent::Register([this](u32 bits) { OnConfigChanged(bits); }, "AbstractGfx"); + m_config_changed = + ConfigChangedEvent::Register([this](u32 bits) { OnConfigChanged(bits); }, "AbstractGfx"); } bool AbstractGfx::IsHeadless() const diff --git a/Source/Core/VideoCommon/AbstractGfx.h b/Source/Core/VideoCommon/AbstractGfx.h index ac51415806..fff8bbf3f6 100644 --- a/Source/Core/VideoCommon/AbstractGfx.h +++ b/Source/Core/VideoCommon/AbstractGfx.h @@ -3,6 +3,7 @@ #pragma once +#include "Common/HookableEvent.h" #include "Common/MathUtil.h" #include "VideoCommon/RenderState.h" @@ -166,6 +167,9 @@ public: protected: AbstractFramebuffer* m_current_framebuffer = nullptr; const AbstractPipeline* m_current_pipeline = nullptr; + +private: + Common::EventHook m_config_changed; }; extern std::unique_ptr g_gfx; From 901f12c9351defd245fb559aa546d7ff3bbeacf4 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Mon, 6 Mar 2023 00:05:30 +1300 Subject: [PATCH 2/2] HookableEvents: Add [[nodiscard]] to Register --- Source/Core/Common/HookableEvent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/HookableEvent.h b/Source/Core/Common/HookableEvent.h index 82a9e57d55..ea012bddf0 100644 --- a/Source/Core/Common/HookableEvent.h +++ b/Source/Core/Common/HookableEvent.h @@ -91,7 +91,7 @@ private: public: // Returns a handle that will unregister the listener when destroyed. - static EventHook Register(CallbackType callback, std::string name) + [[nodiscard]] static EventHook Register(CallbackType callback, std::string name) { auto& storage = GetStorage(); std::lock_guard lock(storage.m_mutex);