From 43bec6a6367dacf1d1ccfe3bfddc186d8fd56c6b Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 15 Mar 2024 21:08:03 +0100 Subject: [PATCH] fix: Make sure pattern runtime is always properly configured --- lib/libimhex/include/hex/providers/provider_data.hpp | 6 +++--- lib/libimhex/source/api/content_registry.cpp | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/libimhex/include/hex/providers/provider_data.hpp b/lib/libimhex/include/hex/providers/provider_data.hpp index fe1d21661..da0d5196f 100644 --- a/lib/libimhex/include/hex/providers/provider_data.hpp +++ b/lib/libimhex/include/hex/providers/provider_data.hpp @@ -74,7 +74,7 @@ namespace hex { return m_data | std::views::values; } - void setOnCreateCallback(std::function callback) { + void setOnCreateCallback(std::function callback) { m_onCreateCallback = std::move(callback); } @@ -84,7 +84,7 @@ namespace hex { auto [it, inserted] = m_data.emplace(provider, T()); auto &[key, value] = *it; if (m_onCreateCallback) - m_onCreateCallback(key, value); + m_onCreateCallback(provider, value); }); EventProviderDeleted::subscribe(this, [this](prv::Provider *provider){ @@ -121,7 +121,7 @@ namespace hex { private: std::map m_data; - std::function m_onCreateCallback; + std::function m_onCreateCallback; }; } \ No newline at end of file diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index cc128734e..a922e18c2 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -533,6 +533,11 @@ namespace hex { pl::PatternLanguage& getRuntime() { static PerProvider runtime; + AT_FIRST_TIME { + runtime.setOnCreateCallback([](prv::Provider *provider, pl::PatternLanguage &runtime) { + configureRuntime(runtime, provider); + }); + }; return *runtime; }