From 35d68d2f82d42c2b0947f2a298c8658e6ad22df8 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 21 Feb 2018 22:47:41 +1100 Subject: [PATCH] Fix crash when iterating through options on window creation Window::on_option_changed calls hooks, which can do anything including adding/removing options in the various option managers Fixes #1863 --- src/window.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/window.cc b/src/window.cc index b64d0fae..d0e0ff85 100644 --- a/src/window.cc +++ b/src/window.cc @@ -30,7 +30,10 @@ Window::Window(Buffer& buffer) setup_builtin_highlighters(m_builtin_highlighters.group()); - for (auto& option : options().flatten_options()) + // gather as on_option_changed can mutate the option managers + for (auto& option : options().flatten_options() + | transform([](auto& ptr) { return ptr.get(); }) + | gather>()) on_option_changed(*option); }