Skip to content

Commit

Permalink
Fix for a crash when using FileIcon to load certain remote icons. Byt…
Browse files Browse the repository at this point in the history
…esIcon works!
  • Loading branch information
italo-capasso committed Jan 1, 2025
1 parent dd81748 commit 4c0048a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Core/Package.vala
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ public class AppCenterCore.Package : Object {

var content_type = msg.response_headers.get_content_type (null);
if (msg.status_code == 200 && content_type != null && content_type.contains ("image")) {
file = File.new_for_uri (remote_icon.get_url ());
file = File.new_for_uri (url);
} else {
warning ("Could not load remote_icon %s: Status error, bad url, or not an image", url);
}
Expand All @@ -744,8 +744,13 @@ public class AppCenterCore.Package : Object {
}
}

if (file != null && file.query_exists ()) {
return new FileIcon (file);
try {
if (file != null && file.query_exists ()) {
// Using FileIcon for some remote icons causes a crash, BytesIcon works though!
return new BytesIcon (file.load_bytes ());
}
} catch (Error e) {
warning ("Failed to load icon %s: %s", get_name (), e.message);
}

uses_generic_icon = true;
Expand Down

0 comments on commit 4c0048a

Please sign in to comment.