Problem calling lua functions

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

Problem calling lua functions

Henrique
Hello there, I've been trying to create a callback for a button using luabind, but when a click the buttons I get a segfault.

Here is the function i use to register the C++ functions to lua:

void Callback::registerCallbacks( lua_State *L ) {
    using namespace luabind;
    module( L ) [
            namespace_("Callback")[
                def( "game_quit", &Callback::game_quit ),
                def( "game_start", &Callback::game_start ),
                def( "game_load", &Callback::game_load ),
                def( "start_battle", &Callback::start_battle )
            ]
    ];
}

This is how i retrieve the function from lua:

typedef LuaFunction luabind::object;
cbk = new LuaFunction( button.getLuaType );

button is of class LuaTable, a wrapper I've made for luabind::object.
cbk is a pointer to a luabind::object.

if I use (*cbk)(); right after, the function runs fine.

But then, I send cbk to a Button constructor which does:
callback = cbk;

And when callback is called inside the button:

void Button::activate(){
    activated = 8;
    (*callback)();
}

I get a segmentation fault.

Thanks.

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user