From 0bb398387b70fa6addd71f772e69fe5966159a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Hamil?= Date: Sat, 28 Feb 2026 19:44:12 +0300 Subject: [PATCH] Refactor wiimote_handler: Replace raw pointer with unique_ptr for instance management --- rpcs3/Input/wiimote_handler.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/rpcs3/Input/wiimote_handler.cpp b/rpcs3/Input/wiimote_handler.cpp index f0197ca0e5..063bee487a 100644 --- a/rpcs3/Input/wiimote_handler.cpp +++ b/rpcs3/Input/wiimote_handler.cpp @@ -205,13 +205,10 @@ bool wiimote_device::update() return true; } -static wiimote_handler* s_instance = nullptr; +static std::unique_ptr s_instance; wiimote_handler::wiimote_handler() { - if (!s_instance) - s_instance = this; - // Pre-initialize Wiimote slots (standard for DolphinBar and typical local multiplayer) for (usz i = 0; i < MAX_WIIMOTES; i++) { @@ -224,8 +221,6 @@ wiimote_handler::wiimote_handler() wiimote_handler::~wiimote_handler() { stop(); - if (s_instance == this) - s_instance = nullptr; } wiimote_handler* wiimote_handler::get_instance() @@ -235,10 +230,10 @@ wiimote_handler* wiimote_handler::get_instance() if (!s_instance) { - s_instance = new wiimote_handler(); + s_instance = std::make_unique(); s_instance->start(); } - return s_instance; + return s_instance.get(); } void wiimote_handler::start()