Re: Wrong userdata pointer returned since update to luabind 0.9
Stefan Reusch <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Here are the two functions...
bool CLuaDialog::Create(const char* Name,
luabind::table<luabind::object> const& Rect) {
CRect r;
if(luabind::type(Rect) == LUA_TTABLE) {
r.SetRect(luabind::object_cast<int>(Rect[1]),
luabind::object_cast<int>(Rect[2]),
luabind::object_cast<int>(Rect[3]),
luabind::object_cast<int>(Rect[4]));
}
CString strWndClass=AfxRegisterWndClass(0,
AfxGetApp()->LoadStandardCursor(IDC_ARROW),GetSysColorBrush(COLOR_WINDOW),NULL);
bool re = !!CLuaWnd<CWnd>::CreateEx(WS_EX_CLIENTEDGE, strWndClass,
UTF8ToUnicode(Name).c_str(), WS_POPUP | WS_CAPTION, r,
AfxGetMainWnd(), 0);
ASSERT(re);
SetFont( CFont::FromHandle(
(HFONT)::GetStockObject(DEFAULT_GUI_FONT)
) );
HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDR_MAINFRAME));
CWnd::SetIcon(hIcon, FALSE);
return re;
}
bool CLuaLabel::Create(luabind::object const& ParentWindow,
luabind::table<luabind::object> const& Rect) {
CRect r;
CLuaWnd<>* pParent = NULL;
if(luabind::type(ParentWindow) == LUA_TUSERDATA) {
pParent = luabind::touserdata<CLuaWnd<>>(ParentWindow);
}
if(luabind::type(Rect) == LUA_TTABLE) {
r.SetRect(luabind::object_cast<int>(Rect[1]),
luabind::object_cast<int>(Rect[2]),
luabind::object_cast<int>(Rect[3]),
luabind::object_cast<int>(Rect[4]));
}
ASSERT(pParent->IsWindowVisible());
bool re = !!CExtLabel::Create(L"Label", WS_CHILD | WS_VISIBLE |
SS_CENTERIMAGE | SS_NOTIFY /*| WS_TABSTOP | WS_BORDER | ES_AUTOHSCROLL
| ES_LEFT*/, r, pParent, 1);
ASSERT(re);
SetFont( CFont::FromHandle(
(HFONT)::GetStockObject(DEFAULT_GUI_FONT)
) );
return re;
}
The code has worked before i switched to luabind 0.9, but perhaps you
has an idea what the problem is...
http://clip2net.com/clip/m7085/1267019396-clip-2kb.png here you can
see the pointer of the dialog object
http://clip2net.com/clip/m7085/1267019455-clip-4kb.png and here one
lua line after (the lualabel call) with a different pointer of dialog
object
2010/2/24 Daniel Wallin <[email protected]>:
> On Wed, Feb 24, 2010 at 01:26:06PM +0100, Stefan Reusch wrote:
>> I have switched to luabind 0.9 and now the userdata pointer are wrong,
>> which are returned. Any ideas to fix the problem? LuaLabel gets in my
>> example a LuaDialog object as parent, but the userdata object pointer
>> is not the same, which it was on create function.
>
> I don't understand. Can you show the relevant functions,
> CLuaLabel::Create() and LuaDialog::Create()?
>
>> [...]
>> OptionDlg = LuaDialog()
>> Label = LuaLabel()
>> Button = LuaButton()
>>
>> function OnSettings()
>> OptionDlg:Create("Settings", {0,0,100,100})
>> Label:Create(OptionDlg, {0,0,100,10}) -- Problem is here: the
>> optiondlg object is not the same one line before
>> end
>
> --
> Daniel Wallin
> BoostPro Computing
> http://www.boostpro.com
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev