Skip to content

Commit

Permalink
Stop storing ref to e2funcs(fixes nil access after e2 refresh)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerelictDrone committed Aug 22, 2024
1 parent 5912bd3 commit 4edec3a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lua/wire/client/e2helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,19 @@ end
delayed(1,function()
local E2Mode = E2Helper:RegisterMode("E2")
if E2Mode then
E2Mode.Descriptions = E2Helper.Descriptions
E2Mode.Items = wire_expression2_funcs -- May be worth replacing this with a metatable to fetch the table from global.
local E2ModeMetatable = {
__index = function(self,key)
if key == "Items" then return wire_expression2_funcs end
if key == "Descriptions" then return E2Helper.Descriptions end
return nil
end
}
E2Mode.Items = nil
E2Mode.Descriptions = nil
-- The metatable is needed because storing a ref to wire_expression2_funcs
-- and then causing e2 to reload (like changing extensions) doesn't update the ref
-- or something like that, it causes e2helper to access nil values.
setmetatable(E2Mode,E2ModeMetatable)
E2Mode.ModeSetup = function(E2HelperPanel)
E2HelperPanel.FunctionColumn:SetName("Function")
E2HelperPanel.FunctionColumn:SetWidth(126)
Expand Down

0 comments on commit 4edec3a

Please sign in to comment.