Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: TGUI Bad Alloc using example code  (Read 2141 times)

0 Members and 1 Guest are viewing this topic.

Burp

  • Newbie
  • *
  • Posts: 2
    • View Profile
TGUI Bad Alloc using example code
« 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?

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI Bad Alloc using example code
« Reply #1 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?
TGUI: C++ SFML GUI

Burp

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: TGUI Bad Alloc using example code
« Reply #2 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.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: TGUI Bad Alloc using example code
« Reply #3 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.
TGUI: C++ SFML GUI