Fix gm-editor to work with df.global structs

It was broken because df.global is not a real struct and does not have ._field at all.
develop
Warmist 2015-10-19 18:42:15 +03:00
parent 757c05db86
commit 5fbb950bc2
1 changed files with 8 additions and 2 deletions

@ -173,8 +173,14 @@ end
function GmEditorUi:getSelectedEnumType() function GmEditorUi:getSelectedEnumType()
local trg=self:currentTarget() local trg=self:currentTarget()
local trg_key=trg.keys[self.subviews.list_main:getSelected()] local trg_key=trg.keys[self.subviews.list_main:getSelected()]
if trg.target._field==nil then return nil end
if trg.target:_field(trg_key)==nil then return nil end local ok,ret=pcall(function () --super safe way to check if the field has enum
return trg.target._field==nil or trg.target:_field(trg_key)==nil
end)
if not ok or ret==true then
return nil
end
local enum=trg.target:_field(trg_key)._type local enum=trg.target:_field(trg_key)._type
if enum._kind=="enum-type" then if enum._kind=="enum-type" then
return enum return enum