From 2f9e2c31b725d1b9ba28b0ef1664499676de8326 Mon Sep 17 00:00:00 2001 From: Hue Date: Wed, 11 Mar 2026 18:09:50 +0100 Subject: [PATCH] =?UTF-8?q?util=C2=A0:=20autohide=20window=C2=A0:=20fix=20?= =?UTF-8?q?memory=20leaks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some signal handlers were not getting disconnected, which leaks memory when an autohide window is made and removed (so, effectively, on monitor disconnection and reconnection) --- src/util/wf-autohide-window.cpp | 13 +++++++++---- src/util/wf-autohide-window.hpp | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/util/wf-autohide-window.cpp b/src/util/wf-autohide-window.cpp index 541ae4ad9..5031a98ec 100644 --- a/src/util/wf-autohide-window.cpp +++ b/src/util/wf-autohide-window.cpp @@ -31,7 +31,7 @@ WayfireAutohidingWindow::WayfireAutohidingWindow(WayfireOutput *output, this->update_position(); auto pointer_gesture = Gtk::EventControllerMotion::create(); - pointer_gesture->signal_enter().connect([=] (double x, double y) + signals.push_back(pointer_gesture->signal_enter().connect([=] (double x, double y) { if (this->pending_hide.connected()) { @@ -41,15 +41,15 @@ WayfireAutohidingWindow::WayfireAutohidingWindow(WayfireOutput *output, this->input_inside_panel = true; y_position.animate(0); start_draw_timer(); - }); - pointer_gesture->signal_leave().connect([=] + })); + signals.push_back(pointer_gesture->signal_leave().connect([=] { this->input_inside_panel = false; if (this->should_autohide()) { this->schedule_hide(AUTOHIDE_HIDE_DELAY); } - }); + })); this->add_controller(pointer_gesture); this->setup_autohide(); @@ -90,6 +90,11 @@ WayfireAutohidingWindow::~WayfireAutohidingWindow() { zwf_hotspot_v2_destroy(this->panel_hotspot); } + + for (auto handler : signals) + { + handler.disconnect(); + } } wl_surface*WayfireAutohidingWindow::get_wl_surface() const diff --git a/src/util/wf-autohide-window.hpp b/src/util/wf-autohide-window.hpp index 2324c6d07..cd6cd6c58 100644 --- a/src/util/wf-autohide-window.hpp +++ b/src/util/wf-autohide-window.hpp @@ -79,6 +79,8 @@ class WayfireAutohidingWindow : public Gtk::Window private: WayfireOutput *output; + std::vector signals; + WfOption position; void update_position();