Fix PushStyleVar aliasing the caller's ImVec2 into the style; fix DebugNodeFontGlyph crash
This commit is contained in:
@@ -1 +1 @@
|
|||||||
[[12, "imgui.lua"], [13734, "imgui_demo.lua"], [14667, "imgui_demo_2.lua"], [17742, "imgui_demo_apps.lua"], [19001, "imgui_demo_tools.lua"], [20327, "imgui_demo_widgets.lua"], [22251, "imgui_docking.lua"], [25379, "imgui_dragdrop.lua"], [25671, "imgui_draw.lua"], [30859, "imgui_h.lua"], [33072, "imgui_impl_roblox.lua"], [33859, "imgui_impl_roblox_fonts.lua"], [34637, "imgui_internal.lua"], [37807, "imgui_tables.lua"], [42154, "imgui_tabs.lua"], [43321, "imgui_widgets.lua"], [51845, "imstb_rectpack.lua"], [52291, "imstb_textedit.lua"], [53532, "imstb_truetype.lua"], [56000, "imstd_minstdio.lua"]]
|
[[12, "imgui.lua"], [13741, "imgui_demo.lua"], [14674, "imgui_demo_2.lua"], [17749, "imgui_demo_apps.lua"], [19008, "imgui_demo_tools.lua"], [20334, "imgui_demo_widgets.lua"], [22258, "imgui_docking.lua"], [25386, "imgui_dragdrop.lua"], [25678, "imgui_draw.lua"], [30866, "imgui_h.lua"], [33079, "imgui_impl_roblox.lua"], [33866, "imgui_impl_roblox_fonts.lua"], [34644, "imgui_internal.lua"], [37814, "imgui_tables.lua"], [42161, "imgui_tabs.lua"], [43328, "imgui_widgets.lua"], [51852, "imstb_rectpack.lua"], [52298, "imstb_textedit.lua"], [53539, "imstb_truetype.lua"], [56007, "imstd_minstdio.lua"]]
|
||||||
+7
-3
@@ -8855,7 +8855,11 @@ function ImGui.PushStyleVar(idx, val)
|
|||||||
end
|
end
|
||||||
local var = g.Style[var_info.Key]
|
local var = g.Style[var_info.Key]
|
||||||
g.StyleVarStack:push_back(ImGuiStyleMod(idx, var))
|
g.StyleVarStack:push_back(ImGuiStyleMod(idx, var))
|
||||||
g.Style[var_info.Key] = val
|
if type(val) == "number" then
|
||||||
|
g.Style[var_info.Key] = val
|
||||||
|
else -- copy into the style's own ImVec2: storing the caller's vector would alias it into the style forever
|
||||||
|
var.x = val.x; var.y = val.y
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param idx ImGuiStyleVar
|
--- @param idx ImGuiStyleVar
|
||||||
@@ -19130,8 +19134,8 @@ function ImGui.DebugNodeFontGlyph(font, glyph)
|
|||||||
ImGui.Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph.X0, glyph.Y0, glyph.X1, glyph.Y1)
|
ImGui.Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph.X0, glyph.Y0, glyph.X1, glyph.Y1)
|
||||||
ImGui.Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph.U0, glyph.V0, glyph.U1, glyph.V1)
|
ImGui.Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph.U0, glyph.V0, glyph.U1, glyph.V1)
|
||||||
if glyph.PackId >= 0 then
|
if glyph.PackId >= 0 then
|
||||||
local r = ImFontAtlasPackGetRect(font.OwnerAtlas, glyph.PackId)
|
local r = { uv0 = ImVec2(), uv1 = ImVec2() }
|
||||||
if r then ImGui.Text("PackId: 0x%X (%dx%d rect at %d,%d)", glyph.PackId, r.w, r.h, r.x, r.y) end
|
if font.OwnerAtlas:GetCustomRect(glyph.PackId, r) then ImGui.Text("PackId: 0x%X (%dx%d rect at %d,%d)", glyph.PackId, r.w, r.h, r.x, r.y) end
|
||||||
end
|
end
|
||||||
ImGui.Text("SourceIdx: %d", glyph.SourceIdx)
|
ImGui.Text("SourceIdx: %d", glyph.SourceIdx)
|
||||||
end
|
end
|
||||||
|
|||||||
+5
-1
@@ -8844,7 +8844,11 @@ function ImGui.PushStyleVar(idx, val)
|
|||||||
end
|
end
|
||||||
local var = g.Style[var_info.Key]
|
local var = g.Style[var_info.Key]
|
||||||
g.StyleVarStack:push_back(ImGuiStyleMod(idx, var))
|
g.StyleVarStack:push_back(ImGuiStyleMod(idx, var))
|
||||||
g.Style[var_info.Key] = val
|
if type(val) == "number" then
|
||||||
|
g.Style[var_info.Key] = val
|
||||||
|
else -- copy into the style's own ImVec2: storing the caller's vector would alias it into the style forever
|
||||||
|
var.x = val.x; var.y = val.y
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param idx ImGuiStyleVar
|
--- @param idx ImGuiStyleVar
|
||||||
|
|||||||
@@ -127,8 +127,8 @@ function ImGui.DebugNodeFontGlyph(font, glyph)
|
|||||||
ImGui.Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph.X0, glyph.Y0, glyph.X1, glyph.Y1)
|
ImGui.Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph.X0, glyph.Y0, glyph.X1, glyph.Y1)
|
||||||
ImGui.Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph.U0, glyph.V0, glyph.U1, glyph.V1)
|
ImGui.Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph.U0, glyph.V0, glyph.U1, glyph.V1)
|
||||||
if glyph.PackId >= 0 then
|
if glyph.PackId >= 0 then
|
||||||
local r = ImFontAtlasPackGetRect(font.OwnerAtlas, glyph.PackId)
|
local r = { uv0 = ImVec2(), uv1 = ImVec2() }
|
||||||
if r then ImGui.Text("PackId: 0x%X (%dx%d rect at %d,%d)", glyph.PackId, r.w, r.h, r.x, r.y) end
|
if font.OwnerAtlas:GetCustomRect(glyph.PackId, r) then ImGui.Text("PackId: 0x%X (%dx%d rect at %d,%d)", glyph.PackId, r.w, r.h, r.x, r.y) end
|
||||||
end
|
end
|
||||||
ImGui.Text("SourceIdx: %d", glyph.SourceIdx)
|
ImGui.Text("SourceIdx: %d", glyph.SourceIdx)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
-- Scrolls the demo with everything open (run with --open) and asserts no style value changes
|
||||||
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
local RunService = game:GetService("RunService")
|
||||||
|
local G = require(ReplicatedStorage:WaitForChild("ImGui"))
|
||||||
|
local ImGui = G.ImGui
|
||||||
|
ImGui.CreateContext()
|
||||||
|
ImGui.GetIO().ConfigFlags = bit32.bor(ImGui.GetIO().ConfigFlags, G.ImGuiConfigFlags.NavEnableKeyboard, G.ImGuiConfigFlags.DockingEnable)
|
||||||
|
G.ImGui_ImplRoblox.Init()
|
||||||
|
local style = ImGui.GetStyle()
|
||||||
|
local function snap()
|
||||||
|
local t = {}
|
||||||
|
for k, v in pairs(style) do
|
||||||
|
if type(v) == "number" then t[k] = tostring(v)
|
||||||
|
elseif type(v) == "table" and getmetatable(v) ~= nil and v.x ~= nil then t[k] = v.x .. "," .. v.y; t[k .. "#id"] = v end
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
local ref
|
||||||
|
local frame = 0
|
||||||
|
RunService.Stepped:Connect(function()
|
||||||
|
frame += 1
|
||||||
|
G.ImGui_ImplRoblox.NewFrame()
|
||||||
|
local w0 = ImGui.FindWindowByName("ImGui Sincerely Demo")
|
||||||
|
if w0 and frame > 2 then
|
||||||
|
local io = ImGui.GetIO()
|
||||||
|
-- sweep the mouse over the window so hover-only paths (tooltips etc.) run
|
||||||
|
io:AddMousePosEvent(w0.Pos.x + 30 + (frame * 37) % math.max(1, w0.Size.x - 60), w0.Pos.y + 40 + (frame * 53) % math.max(1, w0.Size.y - 80))
|
||||||
|
io:AddMouseWheelEvent(0, -1)
|
||||||
|
end
|
||||||
|
ImGui.NewFrame()
|
||||||
|
ImGui.DockSpaceOverViewport(0, nil, G.ImGuiDockNodeFlags.PassthruCentralNode)
|
||||||
|
ImGui.ShowDemoWindow(true)
|
||||||
|
ImGui.Begin("Hello, world!"); ImGui.Checkbox("Demo Window", true); ImGui.SliderFloat("float", 0, 0, 1); ImGui.Button("Button"); ImGui.End()
|
||||||
|
ImGui.EndFrame()
|
||||||
|
local w = ImGui.FindWindowByName("ImGui Sincerely Demo")
|
||||||
|
|
||||||
|
ImGui.Render()
|
||||||
|
G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData())
|
||||||
|
if frame == 2 then ref = snap() end
|
||||||
|
if frame > 2 and ref then
|
||||||
|
for k, v in pairs(snap()) do
|
||||||
|
if not rawequal(ref[k], v) then error(("style.%s changed %s -> %s at frame %d"):format(k, tostring(ref[k]), tostring(v), frame)) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if frame == ARG_FRAMES then print("STYLE OK") end
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user