summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-12-16 14:07:22 +1100
committerMaxime Coste <mawww@kakoune.org>2019-12-16 14:07:22 +1100
commitefabe281732fa4a2cb83ab2adf65c840c251101f (patch)
tree6d79605a7a14db665fe3f2747ebf1df2f73844ee /src
parentf8ab9e07804d243b09610b4e8bf7e1edbc5c52c3 (diff)
Fix WinResize hook getting triggered during urgent event processing
WinResize hooks could be triggered during shell evaluation, leading to any state potentially getting mutated after a shell evaluation call.
Diffstat (limited to 'src')
-rw-r--r--src/client.cc1
-rw-r--r--src/window.cc13
-rw-r--r--src/window.hh3
3 files changed, 15 insertions, 2 deletions
diff --git a/src/client.cc b/src/client.cc
index 6ee3cfae..2c84de6b 100644
--- a/src/client.cc
+++ b/src/client.cc
@@ -80,6 +80,7 @@ bool Client::is_ui_ok() const
bool Client::process_pending_inputs()
{
const bool debug_keys = (bool)(context().options()["debug"].get<DebugFlags>() & DebugFlags::Keys);
+ m_window->run_resize_hook_ifn();
// steal keys as we might receive new keys while handling them.
Vector<Key, MemoryDomain::Client> keys = std::move(m_pending_keys);
for (auto& key : keys)
diff --git a/src/window.cc b/src/window.cc
index cbc4deab..8acc7a03 100644
--- a/src/window.cc
+++ b/src/window.cc
@@ -193,8 +193,17 @@ void Window::set_dimensions(DisplayCoord dimensions)
if (m_dimensions != dimensions)
{
m_dimensions = dimensions;
- run_hook_in_own_context(Hook::WinResize, format("{}.{}", dimensions.line,
- dimensions.column));
+ m_resize_hook_pending = true;
+ }
+}
+
+void Window::run_resize_hook_ifn()
+{
+ if (m_resize_hook_pending)
+ {
+ m_resize_hook_pending = false;
+ run_hook_in_own_context(Hook::WinResize,
+ format("{}.{}", m_dimensions.line, m_dimensions.column));
}
}
diff --git a/src/window.hh b/src/window.hh
index 6d3b7393..ad754568 100644
--- a/src/window.hh
+++ b/src/window.hh
@@ -48,6 +48,8 @@ public:
void set_client(Client* client) { m_client = client; }
void clear_display_buffer();
+ void run_resize_hook_ifn();
+
private:
Window(const Window&) = delete;
@@ -66,6 +68,7 @@ private:
DisplayBuffer m_display_buffer;
Highlighters m_builtin_highlighters;
+ bool m_resize_hook_pending = false;
struct Setup
{