When using the Steam API closing the application throws this error
(http://djfallen.com/images/sfml_excep.png)
(I later loaded the debug symbols for ntdll.dll to find the function is RtlFreeHeap())
on any version of SFML since this (https://github.com/SFML/SFML/commit/22f1b85515242c44d7e5a1be1e3960bdf6648b52?diff=unified) commit 'Added support for interfacing with joysticks via DirectInput'. This happens on Windows 7/10 64bit using VS2017 and can be recreated thusly:
#include <SFML/Graphics.hpp>
#include <steam/steam_api.h>
int main()
{
if(SteamAPI_Init())
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
SteamAPI_Shutdown();
}
return 0;
}
Commenting out the two Steam specific lines stops the error from happening. I realise this is probably a Steam problem as much as anything and I shall be reposting this on the developer forums, but I'd like to point it out here as it is likely the next version of SFML (as the current revision all ready does) will break any games by people developing for Steam, who decide to update SFML.
Try this:
#include <SFML/Graphics.hpp>
#include <steam/steam_api.h>
#include <cstdlib>
int main()
{
if(SteamAPI_Init())
{
std::atexit([]{ SteamAPI_Shutdown(); });
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
}
return 0;
}
I have this weird feeling that whatever is going on inside the Steam DLL doesn't like it when applications call through its hooks after it has been shut down.