Lua stack corruption

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Lua stack corruption

brandon stevenson
Hi guys,
I have found a stack corruption in lua that I believe is caused by
luabind. The corruption occurs in the luaexpat callback table when I
set a value to a class bound by luabind. Without setting this value
the callback table is not corrupted. Here is some relevant code, would
be great if you could help me with it.

here is the script,
----------------------------------------------------
print("-- Loading Theme --")

require "lxp"

local theme = Theme()
local curWidget = nil

local function texture(name, args)
   widget = theme : NewWidget(args["name"], nil)

    for i=1,#args do
        if args[i] == "x" then
            --if this is commented out it works fine
            widget[args[i]] = tonumber(args["x"])
        end
    end
end

callbacks = {
    StartElement = function (parser, name, attribs)
        print("Element:",name)
        if name == "texture" then
                print("here")
                texture(name, attribs)
        end
    end
}

parser = lxp.new(callbacks)
local file = io.open("themes/default.xml", "r")

for line in file:lines() do
    print(line)
    parser:parse(line)
    print(parser:getcallbacks()['StartElement'])
end

file:close()

print("-- Finished loading theme --")

---------------------------------------------------------------------
and the code I bind with

---------------------------------------------------------------------
        luabind::module(GetLuaState())[
                luabind::class_<Theme > ("Theme")
                .def(luabind::constructor<>())
                .def("Init", &Theme::Init)
                .def("LoadTheme", &Theme::LoadTheme)
                .def("PushWidget", &Theme::PushWidget)
                .def("NewWidget", &Theme::NewWidgetData)
                .def("NewWindow", &Theme::NewWindowData)
                .property("Image", &Theme::GetImage, &Theme::SetImage),
               
                luabind::class_<WindowData > ("WindowData")
                .def(luabind::constructor<>())
                .def_readwrite("Widgets", &WindowData::Widgets),

                luabind::class_<WidgetData > ("WidgetData")
                .def(luabind::constructor<>())
                .def_readonly("name", &WidgetData::name)
                .def_readwrite("x", &WidgetData::x)
                .def_readwrite("y", &WidgetData::y)
                .def_readwrite("width", &WidgetData::width)
                .def_readwrite("height", &WidgetData::height)
                ];
-----------------------------------------------------------------------------

for more info you can look at
http://www.gamedev.net/community/forums/topic.asp?topic_id=535089

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user