Skip to content

Commit e3833b6

Browse files
authored
Merge branch 'main' into leolost/fix-ws-shellclients
2 parents c2362ff + 7ace625 commit e3833b6

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/ShellClients/HideTracker.vala

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ public class Gala.HideTracker : Object {
3737
Object (display: display, panel: panel);
3838
}
3939

40-
~HideTracker () {
41-
if (hide_timeout_id != 0) {
42-
Source.remove (hide_timeout_id);
43-
}
44-
45-
if (update_timeout_id != 0) {
46-
Source.remove (update_timeout_id);
47-
}
48-
}
49-
5040
construct {
41+
panel.window.unmanaging.connect_after (() => {
42+
// The timeouts hold refs on us so we stay connected to signal handlers that might
43+
// access the panel which was already freed. To prevent that make sure we reset
44+
// the timeouts so that we get freed immediately
45+
reset_hide_timeout ();
46+
reset_update_timeout ();
47+
});
48+
5149
// Can't be local otherwise we get a memory leak :(
5250
// See https://gitlab.gnome.org/GNOME/vala/-/issues/1548
5351
current_focus_window = display.focus_window;
@@ -152,6 +150,13 @@ public class Gala.HideTracker : Object {
152150
});
153151
}
154152

153+
private void reset_update_timeout () {
154+
if (update_timeout_id != 0) {
155+
Source.remove (update_timeout_id);
156+
update_timeout_id = 0;
157+
}
158+
}
159+
155160
public void update_overlap () {
156161
overlap = false;
157162
focus_overlap = false;

0 commit comments

Comments
 (0)