So I've been putting off writing my own custom window classes for over a year now and finally, when pressed for an actual checkboxitem widget, I figured it was the perfect opportunity to finally try out this process. In general, I've been able to get by just adding children or autowindows to accomplish most tasks, but in this case the LUA to populate this particular listbox was getting pretty crazy and I thought consolidating some code in this way would be beneficial for my mental well-being.
So about this process I went, following the tutorial (http://www.cegui.org.uk/wiki/index.php/Create_a_CheckListboxItem) exactly. I noticed one thing, however - this doesn't actually create my class. In other words, my constructor never gets called. Now, I realize this tutorial is dated so maybe it wasn't always this way. I am using CEGUI 0.7.5 now - perhaps this would have been different in .6x - but I don't see it. So, in order to rectify this, I modified the one line which I was pretty sure was the culprit from:
Code: Select all
wfMgr.addFalagardWindowMapping("WindowsLook/CheckListboxItem", "CEGUI/ItemEntry", "WindowsLook/CheckListboxItem", "Falagard/ItemEntry");
to (i use .scheme files so i added it there instead):
Code: Select all
<FalagardMapping WindowType="WindowsLook/CheckListboxItem" TargetType="CEGUI/CheckListboxItem" Renderer="Falagard/ItemEntry" LookNFeel="WindowsLook/CheckListboxItem" />
After reviewing the source for WindowManager and WindowFactoryManager, I'm pretty sure this was the right call. And further, my constructor now does get called. Great! One problem: it crashes immediately afterwards when I try to add it to my ItemListbox on validate. Here is the stack:
Code: Select all
> CEGUIBase_d.dll!CEGUI::Window::removeChildWindow(CEGUI::Window * window=0x0030c88c) Line 938 + 0x9 bytes C++
CEGUIBase_d.dll!CEGUI::Window::addChild_impl(CEGUI::Window * wnd=0x0030c88c) Line 1331 C++
CEGUIBase_d.dll!CEGUI::Window::testClassName(const CEGUI::String & class_name={...}) Line 1369 + 0x39 bytes C++
CEGUIBase_d.dll!CEGUI::ItemListBase::addChild_impl(CEGUI::Window * wnd=0x29b3f160) Line 452 + 0x26 bytes C++
CEGUIBase_d.dll!CEGUI::Window::addChildWindow(CEGUI::Window * window=0x29b3f160) Line 912 + 0x16 bytes C++
CEGUILuaScriptModule_d.dll!tolua_CEGUI_CEGUI_Window_addChildWindow01(lua_State * tolua_S=0x03a4b2d0) Line 15435 + 0xf bytes C++
Basically, the way I see what's happening here is in the first line of ItemListBase::addChild_impl, the ItemListbox is testing to make sure this is an ItemEntry so that it can add it to the box. When Window::testClassName is called, however, the breakpoint I set in the ItemEntry::testClassName_impl and the custom CheckListItem::testClassName_impl are not hit. Furthermore, the next call up in the stack is Window::addChild_impl - which isn't in any of the testClassName_impl implementations as far as I can tell. So I have to assume that's coming from the original ItemListBase::addChild_impl and the testClassName has returned false.
Now, the nature of the crash is a bad pointer assigned to "this" in Window::removeChildWindow, which is the return of wnd->getParent in Window::addChild_impl. Indeed, the wnd* pointer when I look at it here appears okay (meaning not Badfood or 0xcccccccc - but it's probably still corrupt which is why the parent comes back broken), but it's not the same as the one I am assuming is being passed in in ItemListBase::addChild_impl (it is consistantly led with double 00's where the pointer I'm assuming being passed is not.)
Can anyone shed any light here? I've assumed up and down that this must be a DLL issue, but I've rebuilt everything a number of times and I still get the same error. And if I merely change that one line back, so that it uses the CEGUI::ItemEntry constructor, it runs fine (although its missing the point a little bit I think.)
Thanks for any help,
Alex