added queue to prevent creating images off main thread

This commit is contained in:
2021-11-08 18:22:16 -06:00
parent ca17b1c2dc
commit fcc0212e3d

View File

@@ -4,6 +4,8 @@ class W3DHub
def setup def setup
window.show_cursor = true window.show_cursor = true
@main_thread_queue = []
theme({ theme({
TextBlock: { TextBlock: {
text_border: false, text_border: false,
@@ -119,6 +121,14 @@ class W3DHub
populate_game_page(W3DHub::Game.games.first) populate_game_page(W3DHub::Game.games.first)
end end
def update
super
while(block = @main_thread_queue.shift)
block&.call
end
end
def populate_game_page(game) def populate_game_page(game)
@focused_game = game @focused_game = game
@@ -169,7 +179,7 @@ class W3DHub
unless @game_news[game.slot] unless @game_news[game.slot]
Thread.new do Thread.new do
fetch_game_news(game) fetch_game_news(game)
populate_game_news(game) @main_thread_queue << proc { populate_game_news(game) }
end end
@game_news_container.clear do @game_news_container.clear do
@@ -204,7 +214,7 @@ class W3DHub
flow(width: 0.5, height: 128, margin: 4) do flow(width: 0.5, height: 128, margin: 4) do
# background 0x88_000000 # background 0x88_000000
image "#{GAME_ROOT_PATH}/media/icons/ia.png", width: 0.4 image game.icon, width: 0.4
stack(width: 0.6, height: 1.0) do stack(width: 0.6, height: 1.0) do
stack(width: 1.0, height: 112) do stack(width: 1.0, height: 112) do