From 268d8590435d3005307e1629eefa7424a5683ca4 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 4 Jul 2026 13:04:02 +0200 Subject: [PATCH] fix(reload): reset pending bar-batch state on rebind On reload the GApplication is recreated but the default main context (and any queued PRIORITY_HIGH_IDLE createBarsBatch source) survives. pending_outputs_ was left holding dangling waybar_output* into the just-cleared outputs_ list; createBarsBatch filters by address, which can mis-match once a freed slot is reused. Clear pending_outputs_ and reset bars_scheduled_ in bindInterfaces so the next run batches from a clean state. Mitigates the dangling-pointer path of #4129 (the cross-process app-id race in #4117 is separate). --- src/client.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/client.cpp b/src/client.cpp index 511e35af..d09de5bd 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -286,6 +286,15 @@ void waybar::Client::bindInterfaces() { // Clear stale outputs from previous run outputs_.clear(); + // Also drop any batch state that was left pending from the previous run. On + // reload the GApplication is swapped but the default main context (and its + // queued PRIORITY_HIGH_IDLE createBarsBatch source) survives; pending_outputs_ + // would then hold dangling waybar_output* into the just-cleared outputs_ list, + // which createBarsBatch's address comparison can mis-match if the freed slot is + // reused. Reset so the next run schedules its batch from a clean state (#4129). + pending_outputs_.clear(); + bars_scheduled_ = false; + // add existing outputs and subscribe to updates for (auto i = 0; i < gdk_display->get_n_monitors(); ++i) { auto monitor = gdk_display->get_monitor(i);