mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-30 23:37:17 +03:00
Do not let exception propagate out of register restoring lambda
It is called during a std::vector destruction, which is noexcept, leading to terminate being called.
This commit is contained in:
parent
7325ad216c
commit
da1d78a3c2
@ -1563,7 +1563,14 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
|
||||
auto& register_manager = RegisterManager::instance();
|
||||
auto make_register_restorer = [&](char c) {
|
||||
return on_scope_end([&, c, save=register_manager[c].get(context) | gather<Vector<String>>()] {
|
||||
try
|
||||
{
|
||||
RegisterManager::instance()[c].set(context, save);
|
||||
}
|
||||
catch (runtime_error& err)
|
||||
{
|
||||
write_to_debug_buffer(format("failed to restore register '{}': {}", c, err.what()));
|
||||
}
|
||||
});
|
||||
};
|
||||
Vector<decltype(make_register_restorer(0))> saved_registers;
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
{ other.m_valid = false; }
|
||||
|
||||
[[gnu::always_inline]]
|
||||
~OnScopeEnd() { if (m_valid) m_func(); }
|
||||
~OnScopeEnd() noexcept(noexcept(std::declval<T>()())) { if (m_valid) m_func(); }
|
||||
|
||||
private:
|
||||
bool m_valid;
|
||||
|
Loading…
Reference in New Issue
Block a user