Skip to content

Commit

Permalink
HideTracker: Disconnect timeouts on unmanaging
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Feb 15, 2025
1 parent 3988012 commit 9f3f4c2
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/ShellClients/HideTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ public class Gala.HideTracker : Object {
Object (display: display, panel: panel);
}

~HideTracker () {
if (hide_timeout_id != 0) {
Source.remove (hide_timeout_id);
}

if (update_timeout_id != 0) {
Source.remove (update_timeout_id);
}
}

construct {
panel.window.unmanaging.connect_after (() => {
// The timeouts hold refs on us so we stay connected to signal handlers that might
// access the panel which was already freed. To prevent that make sure we reset
// the timeouts so that we get freed immediately
reset_hide_timeout ();
reset_update_timeout ();
});

// Can't be local otherwise we get a memory leak :(
// See https://gitlab.gnome.org/GNOME/vala/-/issues/1548
current_focus_window = display.focus_window;
Expand Down Expand Up @@ -152,6 +150,13 @@ public class Gala.HideTracker : Object {
});
}

private void reset_update_timeout () {
if (update_timeout_id != 0) {
Source.remove (update_timeout_id);
update_timeout_id = 0;
}
}

public void update_overlap () {
overlap = false;
focus_overlap = false;
Expand Down

0 comments on commit 9f3f4c2

Please sign in to comment.