Hi,
While I was creating a game on Mac OS X I noticed that if I declare a static sf :: Sound variable and I set a SoundBuffer to it, then when I close the application it crash with bad errors.
The problem is in the sf::Sound destructor.
On windows everything works fine (with visual studio compiler).
Here is minimal code example:
//=======================
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <map>
//=======================
#include "ResourcePath.hpp"
//======================
using namespace sf;
//static sound declaration
static sf::Sound snd;
int main()
{
sf::Window win;
win.create(VideoMode(1100, 700), "TEST", Style::Titlebar | Style::Close);
win.setVerticalSyncEnabled(true);
sf::SoundBuffer sndb;
sndb.loadFromFile(resourcePath() + "Greenkey.wav");
snd.setBuffer(sndb);
snd.play();
while (win.isOpen())
{
Event ev;
while (win.pollEvent(ev)) {
switch (ev.type) {
case Event::Closed:
win.close();
break;
}
}
win.display();
}
return EXIT_SUCCESS;
}
Here is what XCode says:
https://www.dropbox.com/s/qgy36in0bjkytbp/Prove.png?dl=0