Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

Commit 8260904

Browse files
committed
fix: prevent segfault in status_handler when downloading a game
Issue: #686
1 parent 9327885 commit 8260904

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/ui/views/GamesView/grid/GameCard.vala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ namespace GameHub.UI.Views.GamesView.Grid
310310
_visible_game = vg;
311311

312312
Idle.add(() => {
313-
label.label = game.name;
313+
if (label != null)
314+
label.label = game.name;
314315
src_icon.icon_name = game.source.icon;
315316

316317
src_icons.foreach(w => w.destroy());
@@ -386,7 +387,14 @@ namespace GameHub.UI.Views.GamesView.Grid
386387

387388
private void status_handler(Game.Status s)
388389
{
390+
// Use weak reference to avoid capturing `this` strongly
391+
weak GameCard weak_self = this;
392+
389393
Idle.add(() => {
394+
// early return when GameCard got destructed to prevent segfault
395+
if (weak_self == null)
396+
return Source.REMOVE;
397+
390398
label.label = game.name;
391399
status_label.label = s.description;
392400
favorite_icon.visible = game.has_tag(Tables.Tags.BUILTIN_FAVORITES);

0 commit comments

Comments
 (0)