Skip to content

Commit

Permalink
spectator_hud: fix resolution change (#3506)
Browse files Browse the repository at this point in the history
Spectator HUD has the callin for resolution change (ViewResize)
correctly. However, the reInit() that is called never ends (re)getting
the font. Therefore, after a resolution change, the widget crashes:

    Error in DrawGenesis(): [string "LuaUI/Widgets/gui_spectator_hud.lua"]:1252: attempt to use a deleted font

Fix by moving font (re)initialization from Initialize() to init().
  • Loading branch information
keelefi authored Jul 31, 2024
1 parent 296c4e4 commit 79d5e69
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions luaui/Widgets/gui_spectator_hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,8 @@ local function initGL4()
end

local function init()
font = WG['fonts'].getFont()

viewScreenWidth, viewScreenHeight = Spring.GetViewGeometry()

buildMetricsEnabled()
Expand Down Expand Up @@ -1929,8 +1931,6 @@ function widget:Initialize()

checkAndUpdateHaveFullView()

font = WG['fonts'].getFont()

init()
end

Expand Down

0 comments on commit 79d5e69

Please sign in to comment.