Hi !
I've not been using the SFML for a couple of years, but yesterday I've decided to get back to it. I've reinstalled everything from scratch on my Ubuntu : SFML 2.5 source code + dependencies (development packages), and I have compiled the SFML for dynamic/static and debug/release targets without any problem, just like described in the installation tutorial. I am able to compile and run the tutorial's example program.
Now, my issue is that when I try to change a RenderWindow's title in my main program's loop, my laptop irremediably freezes... I've tested Debug and Release configurations, both end up crashing and not even showing the window to the screen. What is funny is that I don't run into this issue if I change the window's title before the main loop. So the issue seems related to setTitle being called in this particular context.
Code to reproduce the issue :
#include <SFML/Graphics.hpp>
#include <string>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "Test");
sf::Clock clock;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
float fps = 1.0f / clock.getElapsedTime().asSeconds();
window.setTitle("FPS: " + std::to_string(fps));
window.clear();
window.display();
}
return 0;
}
CMakeLists :
cmake_minimum_required(VERSION 3.14)
project(TestProject)
set(CMAKE_CXX_STANDARD 14)
find_package(SFML 2.5 COMPONENTS graphics window system REQUIRED)
add_executable(TestProject src/main.cpp)
target_link_libraries(TestProject sfml-graphics sfml-window sfml-system)
Note : i had libsfml-dev previously installed (from apt-get), but as I realized it wasn't the latest version, I removed it (with apt remove) before I built SFML 2.5 from sources...
I am not sure whether my issue is related to my installation of the SFML, or to the SFML itself... or to my build configuration ?
Thank you for your time.