From ef9c54b1bfeabfba67aeca907489d90d2e2b7c96 Mon Sep 17 00:00:00 2001 From: Andre Herbst Date: Sat, 30 Nov 2024 11:48:50 +0100 Subject: [PATCH] fix: prevent segfault in status_handler when downloading a game in list view --- src/ui/views/GamesView/list/GameListRow.vala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ui/views/GamesView/list/GameListRow.vala b/src/ui/views/GamesView/list/GameListRow.vala index 6b794e42..e1c40074 100644 --- a/src/ui/views/GamesView/list/GameListRow.vala +++ b/src/ui/views/GamesView/list/GameListRow.vala @@ -270,7 +270,14 @@ namespace GameHub.UI.Views.GamesView.List private void status_handler(Game.Status s) { + // Use weak reference to avoid capturing `this` strongly + weak GameListRow weak_self = this; + Idle.add(() => { + // early return when GameCard got destructed to prevent segfault + if (weak_self == null) + return Source.REMOVE; + label.label = game.name; status_label.label = s.description; tooltip_markup = """%s""".printf(game.name.replace("&", "&").replace("&", "&")) + "\n" + """%s""".printf(s.description.replace("&", "&").replace("&", "&"));