fix: Make sure pattern runtime is always properly configured
This commit is contained in:
parent
6eb9c750a7
commit
43bec6a636
@ -74,7 +74,7 @@ namespace hex {
|
|||||||
return m_data | std::views::values;
|
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);
|
m_onCreateCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ namespace hex {
|
|||||||
auto [it, inserted] = m_data.emplace(provider, T());
|
auto [it, inserted] = m_data.emplace(provider, T());
|
||||||
auto &[key, value] = *it;
|
auto &[key, value] = *it;
|
||||||
if (m_onCreateCallback)
|
if (m_onCreateCallback)
|
||||||
m_onCreateCallback(key, value);
|
m_onCreateCallback(provider, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
EventProviderDeleted::subscribe(this, [this](prv::Provider *provider){
|
EventProviderDeleted::subscribe(this, [this](prv::Provider *provider){
|
||||||
@ -121,7 +121,7 @@ namespace hex {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<const prv::Provider *, T> m_data;
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -533,6 +533,11 @@ namespace hex {
|
|||||||
|
|
||||||
pl::PatternLanguage& getRuntime() {
|
pl::PatternLanguage& getRuntime() {
|
||||||
static PerProvider<pl::PatternLanguage> runtime;
|
static PerProvider<pl::PatternLanguage> runtime;
|
||||||
|
AT_FIRST_TIME {
|
||||||
|
runtime.setOnCreateCallback([](prv::Provider *provider, pl::PatternLanguage &runtime) {
|
||||||
|
configureRuntime(runtime, provider);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return *runtime;
|
return *runtime;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user