Troubles with ListBox[Solved]

Started by Austin J, 15 August 2014, 07:35:39

Austin J

If I add a  ListBox like this, I end up with a crash upon calling tgui::Gui::draw()

tgui::ListBox::Ptr textures_listBox(gui,"Textures List");

textures_listBox->load("graphics/gui/Black.conf"); // Load is returning true
sf::Vector2i screenSize(sf::VideoMode::getDesktopMode().width,sf::VideoMode::getDesktopMode().height);
textures_listBox->setPosition(screenSize.x - 200, 0);
textures_listBox->addItem("Test Item");

Tgui version 0.6

SFML Version, the one shipped with this version of Tgui

IDE - Visual Studio 2012

The gui has a window set to it

load("graphics/gui/Black.conf") is returning true

All other widgets I use are working fine, it's just ListBox that doesn't seem to behave.

When it reaches gui.draw(), I get this

Unhandled exception at 0x5DA942EF (sfml-graphics-2.dll) in Aeldyr Editor.exe: 0xC0000005: Access violation reading location 0x4491C004.

I apologize, I'd have done a bit more research on this but there's very little documentation for ListBox. I've tried a variety of things and I keep getting this access error.


And you are 100% sure that you are linking tgui in the same way as sfml? (both dynamic or both static, both release in release mode and both debug in debug mode).

If so then could you send me your project file(s)?

Austin J

Yeah, I'm linking dynamically to both. I guess I'll have to send them to you.


I just need the vcxproj file. If your code is just a single file then you can send that as well.

Those files should even be small enough to be added as an attachment to your post.

Just to be sure, you have v0.6.5, right?

Austin J

I'll send the project file, not the code unless we think we need it to solve this issue though because it's an actual project. It's a map editor for a game, so there is a bit of a codebase. (Not that big just not small enough to throw on here ;) - )

I'm using version 0.6, I think I started using it with this before you got version 0.6.5 out.


The library paths in release mode seem right, but the ones in debug mode are wrong.

C:\SFML 2.1 -32\SFML-2.1\lib
Should be

Oh, and the include directory doesn't need "C:\TGUI-0.6\include\SFML". But that doesn't really matter.

Edit: I now see that the include directory in debug mode is also set to the wrong sfml version.

So unless you were experiencing the crash in release mode, it should be solved after changing library and include paths.

Austin J

Yeah sorry, I should have mentioned originally I was using the wrong SFML versions, so I switched to the versions you shipped out for release mode, I didn't change it in debug. In release mode this problem is occurring.


I'm going to have a look if I can reproduce it.

In the meantime you can change your settings to also work in debug, and revert the order of the libraries (first system, then window, ..., finally tgui). And then rebuild the project. Just to be sure that neither of these things influence the crash.

Austin J

Changed the settings to as you said and sadly no fix  :'(

I've also discovered gui.draw() causes a crash if I add a MenuBar to the gui.


Are u perhaps still using the dlls of the old sfml version?

The crash really indicates that there is some incompatibilities in the libraries.
TGUI v0.6.5 has just been build and thus not yet tested, but if you really have v0.6.4 (search PATCH_VERSION in CMakeLists.txt to be sure) then it can't really be a mistake on my side.

Austin J

That thought had actually come to mind when I was changing the debug settings, and after getting some confirmation from reading your response there I went ahead and replaced the dlls. Sure enough everything seems to be working fine now. I completely wasted your time there, apologies sir, I don't know why I didn't use the dlls you shipped in the first place. Thank you for your patience!


Its ok, you can't help it that windows is such a pain to develop with :).
The smallest mistake leads to strange crashes, and its always hard to find out which mistake you made.