MenuBar problem

Started by roccio, 10 May 2018, 14:35:36

roccio

Hello,
I have updated SFML to 2.5.0 and TGUI 0.8 dev all compiled with source by myself.
It all works well, but I have a problem when using tgui::Menubar.

What I do is just this:
- load a font
- set this font to tgui::gui
- create a MenuBar
- add menubar to gui

then normal event processing and rendering.

All works, only when I close the program I have this error:

Failed to activate OpenGL context: Operazione completata.

An internal OpenGL call failed in Texture.cpp(117).
Expression:
   glDeleteTextures(1, &texture)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.


This is not happening if I just don't add the menubar to gui.

Is there something I miss?

texus

Looks like something isn't being destroyed before the end of the main function. SFML textures (which are also used inside a font) can't exist in global scope. If a reference to the menu bar still exists at the end of the program then you could get issues like this.
If neither the font, gui or menu bar are static variables then you should try reducing the code to a simple example that still crashes.

roccio

Here it is:


int main(int argc, char** argv)
{
sf::RenderWindow window;
sf::Font font;
tgui::Gui gui;

window.create(sf::VideoMode(800, 600), VERSION, sf::Style::Close);
window.setFramerateLimit(60);

font.loadFromFile("fonts\\segoeui.ttf");
gui.setTarget(window);
gui.setFont(font);

tgui::MenuBar::Ptr  menu = tgui::MenuBar::create();
gui.add(menu);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
return 0;

gui.handleEvent(event);
}
window.clear(sf::Color(223, 223, 223));
gui.draw();
window.display();
}

return 9;


Just comment the
gui.add(menu);

and no errors on exit

texus

It might not be so easy to reproduce (it doesn't give any errors here and valgrind doesn't show anything useful). So I'm going to need to get a similar setup as yours:
What compiler are you using? Are you linking statically or dynamically? Release or debug mode?

roccio

I'm using Visual C++ 2015 and using dynamic link.

roccio

To not have the error you can comment the gui.add(menu) line OR gui.setFont(font);

:-\

texus

I managed to reproduce it (the code can even be simplified further, the sfml window and main loop can be removed and it still occurs), but I haven't figured out yet what could be causing it. But it is definitely a problem inside TGUI.

texus


roccio

Seems to work well now.
Thank you, great work!