1
0
mirror of synced 2024-11-12 02:00:52 +01:00

fix: Make sure pattern runtime is always properly configured

This commit is contained in:
WerWolv 2024-03-15 21:08:03 +01:00
parent 6eb9c750a7
commit 43bec6a636
2 changed files with 8 additions and 3 deletions

View File

@ -74,7 +74,7 @@ namespace hex {
return m_data | std::views::values;
}
void setOnCreateCallback(std::function<void(const prv::Provider *, T&)> callback) {
void setOnCreateCallback(std::function<void(prv::Provider *, T&)> 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<const prv::Provider *, T> m_data;
std::function<void(const prv::Provider *, T&)> m_onCreateCallback;
std::function<void(prv::Provider *, T&)> m_onCreateCallback;
};
}

View File

@ -533,6 +533,11 @@ namespace hex {
pl::PatternLanguage& getRuntime() {
static PerProvider<pl::PatternLanguage> runtime;
AT_FIRST_TIME {
runtime.setOnCreateCallback([](prv::Provider *provider, pl::PatternLanguage &runtime) {
configureRuntime(runtime, provider);
});
};
return *runtime;
}