SFML community forums

Help => General => Topic started by: Burp on November 02, 2017, 06:38:46 am

Title: TGUI Bad Alloc using example code
Post by: Burp on November 02, 2017, 06:38:46 am
Hello,

While looking for a GUI library I came across tgui which seemed interesting and supposedly offers exactly what I need.

After trying to implement a simple login window for the project I am working on, I kept running into a std::bad_alloc exception. After scratching my head for a while I figured I should just try the examples and see if that works.

Turns out that gives me the exact same error...

Exception:
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Example I tried:
https://tgui.eu/examples/0.8/scalable-login-screen/

The exception is thrown upon calling gui.add();

Any suggestions / ideas what might be causing this?
Title: Re: TGUI Bad Alloc using example code
Post by: texus on November 02, 2017, 06:31:27 pm
I don't know what could cause it.
Did you build TGUI yourself with cmake of did you download VS2015 binaries it from the website?
What compiler are you using?
Which SFML version are you using?
Title: Re: TGUI Bad Alloc using example code
Post by: Burp on November 03, 2017, 03:43:09 am
Was using 0.7.5 but changed it to the latest develop branch. Seems to be working now.
Title: Re: TGUI Bad Alloc using example code
Post by: texus on November 03, 2017, 07:53:07 am
I assumed you were using 0.8 because you linked the example code for that version.
TGUI 0.7 and 0.8 are not compatible at all, although this simple example compiled, it did something completely different. The "50%" means "parent.width / 2" in 0.8 while it means "50 mod 0" in 0.7. The division by 0 might somehow be causing the crash. I have been able to reproduce it in 0.7 and will fix it in 0.7.6 as the code shouldn't crash for something like this.