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

Author Topic: Stack overflow while creating sf::RenderTexture in other thread  (Read 1826 times)

0 Members and 1 Guest are viewing this topic.

JAKUBW

  • Newbie
  • *
  • Posts: 8
    • View Profile
Hey

I try to create sf::RenderTexture object in std::thread method and it causes stack overflow.
My code:
#include <SFML/Graphics.hpp>
#include <thread>

int main()
{
        sf::RenderTexture texture;
        std::thread thread([]() {
                sf::RenderTexture t;
        });

        thread.join();
        return 0;
}
 
Without creating first texture it happens too.
#include <SFML/Graphics.hpp>
#include <thread>

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "WINDOW");

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                        if (event.type == sf::Event::MouseButtonPressed)//crash when button is pressed
                        {
                                std::thread thread([]() {
                                        sf::RenderTexture t;
                                });
                        }
                }
                window.clear(sf::Color(50, 50, 50));
                window.display();
        }
        return 0;
}
 
but it doesn't crash with this code:
#include <SFML/Graphics.hpp>
#include <thread>

int main()
{
        std::thread thread([]() {
                sf::RenderTexture t;
        });
        thread.join();
        return 0;
}

How to solve this problem?

SFML 2.4.2
Microsoft Visual Studio Community 2015, Version 14
« Last Edit: June 23, 2017, 05:00:30 pm by JAKUBW »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Stack overflow while creating sf::RenderTexture in other thread
« Reply #1 on: June 24, 2017, 12:36:45 am »
This issue has been fixed in SFML 2.4.2. I tested it with MinGW and VS 2017 and it works fine.

If you've update from 2.4.x to 2.4.2 make sure to replace the DLLs as well.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

JAKUBW

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Stack overflow while creating sf::RenderTexture in other thread
« Reply #2 on: June 24, 2017, 10:24:42 pm »
Oh yeah, I updated files, but I didn't replace dll's...
Thank you very much :)

 

anything