Skip to content

Commit

Permalink
fix: prevent segfault in status_handler when downloading a game in li…
Browse files Browse the repository at this point in the history
…st view
  • Loading branch information
moormaster committed Nov 30, 2024
1 parent 7cca449 commit ef9c54b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ui/views/GamesView/list/GameListRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """<span weight="600">%s</span>""".printf(game.name.replace("&amp;", "&").replace("&", "&amp;")) + "\n" + """<span size="smaller">%s</span>""".printf(s.description.replace("&amp;", "&").replace("&", "&amp;"));
Expand Down

0 comments on commit ef9c54b

Please sign in to comment.