Assertion Error when using VerticalLayout and bindWidth/bindHeight

Started by cookie, 07 December 2015, 00:48:20


Hey there,
I'm using the precompiled TGUI v0.7-alpha2 for Visual C++14 (2015) 32 bit with SFML-2.3.2. I have linked it static.
Since I just had started using this awesome library, I copied the example code ( for the scalable login screen and modified it to produce the error.
The scalable screen worked well when I directly attached the widgets to the gui like in the original example, but when I have started using the tgui::VerticalLayout things get a bit wired.
When I uncomment line 21 where I insert a space in between the two buttons in the layout, it will throw a assertion error when you scale the window on the y axis. Scaling on the x axis works perfectly. It also works perfect if there is no space in the layout or if I don't use a layout at all.

The error occours in line 56 when gui.setView(window.getView()); is called.

The exact error:

Debug Assertion Failed!
File: [...]\Microsoft Visual Studio\14.0\VC\include\vector
Line: 101
Vector iterator not incrementable

The release mode will also throw an error, but a little bit different.

The code used to get this error:
(mostly the example)
#include <TGUI/TGUI.hpp>

void loadWidgets(tgui::Gui& gui)
// Create GUI
// Update size on window resize
auto windowWidth = tgui::bindWidth(gui);
auto windowHeight = tgui::bindHeight(gui);

// Vertical Layout
auto MenuLayout = std::make_shared<tgui::VerticalLayout>();
MenuLayout->setSize(windowWidth * 0.6f, windowHeight * 0.8f);
MenuLayout->setPosition(windowWidth * 0.2f, windowHeight * 0.1f);

// Play Button
auto PlayBtn = std::make_shared<tgui::Button>();

/* ### Error line ### */

// Exit Button
auto ExitBtn = std::make_shared<tgui::Button>();

int main()
// Create the window
sf::RenderWindow window(sf::VideoMode(400, 300), "TGUI window");
tgui::Gui gui(window);

try {
// Load the font

// Load the widgets
} catch(const tgui::Exception& e) {
std::cerr << "Failed to load TGUI widgets: " << e.what() << std::endl;
return 1;

// Main loop
while(window.isOpen()) {
sf::Event event;
while(window.pollEvent(event)) {
// When the window is closed, the application ends
if(event.type == sf::Event::Closed)

// When the window is resized, the view is changed
else if(event.type == sf::Event::Resized) {
window.setView(sf::View(sf::FloatRect(0, 0, event.size.width, event.size.height)));

// Pass the event to all the widgets


// Draw all created widgets



Thanks for your help :)



It seems like this bug has already been fixed in the latest version, you can download it from github. You have to build it yourself with CMake.

You made me realize that the latest version on my download page is v0.7-alpha2. I will add a link to the source code of the latest snapshot as well, because there have already been quite some bug fixes.


Thanks Texus!
The latest code from github worked for me!