Skip to content

Commit

Permalink
Fix leaking Launchers (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 authored Jun 24, 2024

Verified

This commit was signed with the committer’s verified signature.
weblate Weblate (bot)
1 parent 32cd195 commit 92c41cc
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/Launcher.vala
Original file line number Diff line number Diff line change
@@ -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;

@@ -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;

@@ -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;
}
});
}
@@ -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 ();
2 changes: 2 additions & 0 deletions src/LauncherManager.vala
Original file line number Diff line number Diff line change
@@ -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) {

0 comments on commit 92c41cc

Please sign in to comment.