TGUI->handleEvent(*event) on polymorphic class causes SIGSEV: StackHash_0a9e

Started by JohnGreek, 16 August 2014, 17:37:20



I am using TGUI v0.6.5 compiled as shared lib on windows 7 - MinGW.
My IDE is QtCreator and i' m using Qt in conjunction with SFML & TGUI.

I have 3 classes, 1 is pure virtual "GameState", 2 is the "GameWindow" with the sf::RenderWindow and the sf::Event and 3 is a state( the login screen in this situation ) called "LoginScreen" which is inheriting from  "GameState".

I create a GameState pointer(currentState) and assign a new LoginScreen object on it.
Then in the GameWindow main loop i call currentState->HandleEvents, HandleLogic etc.

In my LoginScreen class i have 2 variables passed by reference, the sf::RenderWindow and the sf::Event so all the events on the main window are passed to the LoginScreen. The program crashes when there is a new event on the window at the myGUI->handleEvent(*LoginEvent); This is my LoginScreen::HandleEvent():

void LoginScreen::HandleEvents()
    while( LoginWindow->pollEvent(*LoginEvent) )
        if (LoginEvent->type == sf::Event::Closed)

        myGUI->handleEvent(*LoginEvent); <- This is where the crash occurs, tried with commenting out as well

I started the debugger but the only thing i get is (??) at function names and one file;

Like the error is coming from this..
Also, before i implemented the state machine and had only 1 class
as MainWindow the myGUI->handleEvent(*LoginEvent) was working just fine.

Any ideas?


I assume that you are certain that the myGUI and LoginEvent are valid pointers when that line is executed.

The only thing that comes in mind is that you made a small mistake in the configuration (incompatible sfml and tgui libs, read,216.msg1092.html#msg1092). The smallest incompatibility can cause such a crash in either the handleEvent or draw function, and its usually very unpredictable (I have seen multiple different crashes for this reason).

If you are 100% sure that everything has been setup correctly then I'm going to have to test it myself. But I don't have qt, so you would have to come up with some minimal but complete code to reproduce it with just sfml and tgui.


Thanks for your reply.

I found the problem. It's point(2) of your reply about the configuration.

I needed (and still need :P) a fix for the GainedFocus/LostFocus on windows and i took backup of my compiler directory to try and compile SFML with CMAKE but it seems somehow i did something wrong and the git version of SFML was in my backup and compiler directory as well . I found out by checking the sf::String::substring function and it existed in the .hpp file...

I recompiled TGUI again as well just to be sure ;)

Must keep in mind not to mess with the compiler directory that much :D