Skip to content

Commit 4edc806

Browse files
committed
Make thread-safe for Godot v4.1
1 parent 5624b49 commit 4edc806

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

core/boxart_steam.gd

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const _boxart_dir = "user://boxart/steam"
44
const _supported_ext = [".jpg", ".png", ".jpeg"]
55

66
@export var use_caching: bool = true
7+
var http_image := HTTPImageFetcher.new()
78

89
# Maps the layout to a file suffix for caching
910
var layout_map: Dictionary = {
@@ -34,6 +35,7 @@ func _ready() -> void:
3435
super()
3536
logger.info("Steam BoxArt provider loaded")
3637
logger._level = Log.LEVEL.INFO
38+
add_child(http_image)
3739

3840

3941
# Looks for boxart in the local user directory based on the app name
@@ -63,13 +65,9 @@ func get_boxart(item: LibraryItem, kind: LAYOUT) -> Texture2D:
6365

6466
# Try to fetch the artwork
6567
logger.debug("Fetching steam box art for: " + item.name)
66-
var http_image := HTTPImageFetcher.new()
67-
add_child(http_image)
6868
var url: String = layout_url_map[kind].format([steamAppID])
6969
var texture: Texture2D = await http_image.fetch(url, cache_flags)
7070
if texture == null:
7171
logger.debug("Image couldn't be downloaded for: " + item.name)
72-
remove_child(http_image)
73-
http_image.queue_free()
74-
72+
7573
return texture

core/steam_client.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ func bootstrap() -> void:
8383
func install_steamcmd() -> bool:
8484
# Build the request
8585
var http: HTTPRequest = HTTPRequest.new()
86-
add_child(http)
86+
add_child.call_deferred(http)
87+
await http.ready
8788
if http.request(steamcmd_url) != OK:
8889
logger.error("Error downloading steamcmd: " + steamcmd_url)
8990
remove_child(http)

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"plugin.id": "steam",
33
"plugin.name": "Steam",
4-
"plugin.version": "1.0.8",
4+
"plugin.version": "1.0.9",
55
"plugin.min-api-version": "1.0.0",
66
"plugin.link": "https://github.com/ShadowBlip/OpenGamepadUI-steam",
77
"plugin.source": "https://github.com/ShadowBlip/OpenGamepadUI-steam",

0 commit comments

Comments
 (0)