Skip to content

Commit

Permalink
fix: prevent segfault in status_handler when downloading a game
Browse files Browse the repository at this point in the history
Issue: #686
  • Loading branch information
moormaster committed Nov 29, 2024
1 parent 9327885 commit ea151e7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ui/views/GamesView/grid/GameCard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,14 @@ namespace GameHub.UI.Views.GamesView.Grid

private void status_handler(Game.Status s)
{
// Use weak reference to avoid capturing `this` strongly
weak GameCard 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;
favorite_icon.visible = game.has_tag(Tables.Tags.BUILTIN_FAVORITES);
Expand Down

0 comments on commit ea151e7

Please sign in to comment.