Don't crash if class_info() is called on non-luabind objects

* See 2c6c9054e3
This commit is contained in:
squeek 2015-03-24 12:34:20 -07:00
parent 5d8f3cd3ab
commit e5e5e1735b

View file

@ -48,6 +48,20 @@ function baseclass:new (o)
end
-----------------------------------------------------------------------------
-- make luabind's class_info function safer
-- (don't crash if class_info() is called on non-luabind objects)
-----------------------------------------------------------------------------
local class_info_base = class_info
class_info = function(obj)
local obj_type = type(obj)
if obj_type == "userdata" and getmetatable(obj).__luabind_class then
return class_info_base(obj)
end
return {}
end
-----------------------------------------------------------------------------
-- reset everything
-----------------------------------------------------------------------------