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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - SlimShady

Pages: [1]
1
Graphics / Re: sf::Texture::~Texture() Crashes App On Exit
« on: November 15, 2016, 04:30:48 pm »
Even if this isn't the cause of the error, your use of threads is rather dangerous.

Thanks for the quick reply. :) I've felt it was error prone, but now you confirmed it, haha. Thanks for the explanation.

I managed to apply a quick-fix by eliminating the callback and querying the state every frame, like this:

Code: [Select]
if (download.isComplete()) {
    std::string data = download.getData();
    texture.loadFromMemory(data.c_str(), data.length());
    sprite.setTexture(texture);
}

But it's not what I wanted originally. So I guess my question changes to: How do I achieve this using a callback function? Do you have any suggestions on how to improve the code?

2
Graphics / sf::Texture::~Texture() Crashes App On Exit
« on: November 15, 2016, 02:05:49 pm »
Hello peeps,

I've been using SFML for quite some time now, and I have to say that I absolutely love it.

Currently I'm building a game engine + all sorts of tools for my future games, and I just threw together this little file downloader that can be used in combination with SFML resources' loadFromMemory() function.

It all works fine, the image is displayed correctly, but when I close the application, it crashes with an EXC_BAD_ACCESS error and shows me the assemly code for the destructor of the Texture and for some releasePool() method. I cannot seem to figure out why this is happening. It works without any problems with sf::Font and sf::SoundBuffer. Please help.

Download.cpp
(click to show/hide)

main.cpp
(click to show/hide)

If I replace sf::Texture and sf::Sprite with sf::Font and sf::Text respectively (and change the URL obviously), there is no problem at all.

Pages: [1]