Hi John,

Latest CVS, but still not :-(

John Labenski wrote:

> It is normal that it can't find the object when you're registering the
> bindings since it's being push for the first time. The whole idea
> behind the check for wxluaO_istrackedweakobject() is that we don't
> want to create multiple Lua userdata wrapping our C++ object, but push
> the same one again. However, just like in C++ the object can be cast
> to different types and wxLua must create new userdata for each type to
> distinguish them (for wxObject::DynamicCast()).

Oke, i thought it would be something like that ;-)

> 
> Exactly, the second time through it finds that the object was already
> pushed, but with a different type so as far as wxLua is concerned,
> it's not what we want and returns false.

oke.

> 
>> ===============Stack ================
>>
>> luaO_rawequalObj(const lua_TValue * 0x4d6584b1, const lua_TValue * 
>> 0x02006608)
>> line 73 + 6 bytes
>> luaH_get(Table * 0x02174b60, const lua_TValue * 0x02006608) line 484 + 16 
>> bytes
>> luaH_set(lua_State * 0x02006318, Table * 0x02174b60, const lua_TValue *
>> 0x02006608) line 495 + 13 bytes
>> lua_rawset(lua_State * 0x02006318, int -3) line 673 + 37 bytes
> 
> ??? What happens here?

LUA_API void lua_rawset (lua_State *L, int idx) {

.......... In the next liene it goes to luaH_set, where you can see above it 
goes a bit further and generates the exception. I examined L and t.

   setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
..........
}

But in luaH_set calls luaH_get

const TValue *luaH_get (Table *t, const TValue *key) {

These input parameters here e.g parameter t is weird, so i think  L->top-2 is 
not oke. It contains a lots of "expression  cannot be evaluated" when i 
QuickWatch it.

}

So i think the lua stack is already not oke before calling lua_rawset.

> 
> wxLuaBinding::DoRegisterBinding
> ...
>     if (wxlObject->objPtr != 0)
>         wxluaT_pushuserdatatype(L, wxlObject->objPtr,
> *wxlObject->wxluatype, true);

NO it goes into the else of the if, because its a pointer i think.

         if (wxlObject->objPtr != 0)
             wxluaT_pushuserdatatype(L, wxlObject->objPtr, 
*wxlObject->wxluatype, true);
         else //HERE
             wxluaT_pushuserdatatype(L, *wxlObject->pObjPtr, 
*wxlObject->wxluatype, true);

AND IN THE NEXT LINE ALL IS WRONG
         lua_rawset(L, -3);
> 
> then
> 
> bool LUACALL wxluaT_pushuserdatatype
> ...
>             if (wxluaR_getref(L, wxl_type, &wxlua_lreg_types_key))
>             {
>                 // pop the table and set it as the metatable for the 
> newuserdata
>                 lua_setmetatable(L, -2);
> 
>                 if (track)
>                     wxluaO_trackweakobject(L, -1, (void*)obj_ptr, wxl_type);

It goes in here.

> 
>                 return true; // leave value on the stack

And returns here.

>             }
> 
> Does it crash in wxluaO_trackweakobject() or wxluaR_getref()?

Euuh, no it crashes exactly as the stack above shows, luaO_rawequalObj, put i 
think the damage is already done at/before that moment.
For some reason i think what is done in wxluaT_pushuserdatatype is ruining the 
rest.

Thanks,

Klaas

-- 
Unclassified

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to