From f8dc733d8e01cc6ecd9b4115f9e62c2ea0d784cd Mon Sep 17 00:00:00 2001 From: denvoros Date: Fri, 3 Oct 2025 08:35:36 -0600 Subject: [PATCH] fix: ControllerInterface map reworked to a static getter --- .../Source/Controllers/ControllerDescriptor.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/Controllers/ControllerDescriptor.cpp b/SerialPrograms/Source/Controllers/ControllerDescriptor.cpp index e06b431e2c..fec28962e6 100644 --- a/SerialPrograms/Source/Controllers/ControllerDescriptor.cpp +++ b/SerialPrograms/Source/Controllers/ControllerDescriptor.cpp @@ -21,14 +21,17 @@ namespace PokemonAutomation{ // // Here we store a map of all controller types in the program. // -std::map> ALL_CONTROLLER_INTERFACES; +static std::map>& all_controller_interfaces(){ + static std::map> instance; + return instance; +} void InterfaceType::register_factory( ControllerInterface controller_interface, std::unique_ptr factory ){ - auto ret = ALL_CONTROLLER_INTERFACES.emplace(controller_interface, std::move(factory)); + auto ret = all_controller_interfaces().emplace(controller_interface, std::move(factory)); if (!ret.second){ throw InternalProgramError( nullptr, PA_CURRENT_FUNCTION, @@ -76,7 +79,7 @@ void ControllerOption::load_json(const JsonValue& json){ break; } - for (const auto& item : ALL_CONTROLLER_INTERFACES){ + for (const auto& item : all_controller_interfaces()){ const JsonValue* params = obj->get_value(CONTROLLER_INTERFACE_STRINGS.get_string(item.first)); if (params == nullptr){ continue;