parent
014cd50883
commit
089eaa52e0
|
@ -51,6 +51,16 @@ void HookManager::run_hook(StringView hook_name,
|
||||||
if (hook_list_it == m_hook.end())
|
if (hook_list_it == m_hook.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (contains(m_running_hooks, std::make_pair(hook_name, param)))
|
||||||
|
{
|
||||||
|
auto error = format("recursive call of hook {}/{}, aborting", hook_name, param);
|
||||||
|
write_to_debug_buffer(error);
|
||||||
|
throw runtime_error(std::move(error));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_running_hooks.emplace_back(hook_name, param);
|
||||||
|
auto pop_running_hook = on_scope_end([this]{ m_running_hooks.pop_back(); });
|
||||||
|
|
||||||
using Clock = std::chrono::steady_clock;
|
using Clock = std::chrono::steady_clock;
|
||||||
using TimePoint = Clock::time_point;
|
using TimePoint = Clock::time_point;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ private:
|
||||||
|
|
||||||
SafePtr<HookManager> m_parent;
|
SafePtr<HookManager> m_parent;
|
||||||
IdMap<IdMap<HookFunc, MemoryDomain::Hooks>, MemoryDomain::Hooks> m_hook;
|
IdMap<IdMap<HookFunc, MemoryDomain::Hooks>, MemoryDomain::Hooks> m_hook;
|
||||||
|
mutable Vector<std::pair<StringView, StringView>> m_running_hooks;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user