Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix leaking Launchers #249

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/Launcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class Dock.Launcher : Gtk.Box {
private Gtk.Overlay overlay;
private Gtk.PopoverMenu popover;

private Binding current_count_binding;

private int drag_offset_x = 0;
private int drag_offset_y = 0;

Expand Down Expand Up @@ -188,7 +190,7 @@ public class Dock.Launcher : Gtk.Box {
settings.bind ("icon-size", image, "pixel-size", DEFAULT);

app.bind_property ("count-visible", badge_revealer, "reveal-child", SYNC_CREATE);
app.bind_property ("current_count", badge, "label", SYNC_CREATE,
current_count_binding = app.bind_property ("current_count", badge, "label", SYNC_CREATE,
(binding, srcval, ref targetval) => {
var src = (int64) srcval;

Expand All @@ -209,16 +211,18 @@ public class Dock.Launcher : Gtk.Box {
add_controller (drop_target_file);

drop_target_file.enter.connect ((x, y) => {
if (launcher_manager.added_launcher != null) {
calculate_dnd_move (launcher_manager.added_launcher, x, y);
var _launcher_manager = LauncherManager.get_default ();
if (_launcher_manager.added_launcher != null) {
calculate_dnd_move (_launcher_manager.added_launcher, x, y);
}
return COPY;
});

drop_target_file.drop.connect (() => {
if (launcher_manager.added_launcher != null) {
launcher_manager.added_launcher.moving = false;
launcher_manager.added_launcher = null;
var _launcher_manager = LauncherManager.get_default ();
if (_launcher_manager.added_launcher != null) {
_launcher_manager.added_launcher.moving = false;
_launcher_manager.added_launcher = null;
}
});
}
Expand All @@ -228,6 +232,16 @@ public class Dock.Launcher : Gtk.Box {
popover.dispose ();
}

/**
* If the launcher isn't needed anymore call this otherwise it won't be freed.
*/
public void cleanup () {
timed_animation = null;
bounce_down = null;
bounce_up = null;
current_count_binding.unbind ();
}

private void on_click_released (int n_press, double x, double y) {
var event_display = gesture_click.get_current_event ().get_display ();
var context = event_display.get_app_launch_context ();
Expand Down
2 changes: 2 additions & 0 deletions src/LauncherManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@
resize_animation.value_from = get_width ();
resize_animation.value_to = launchers.length () * get_launcher_size ();
resize_animation.play ();

launcher.cleanup ();
}

private void update_launcher_entry (string sender_name, GLib.Variant parameters, bool is_retry = false) {
Expand Down