4
« on: April 12, 2016, 02:18:17 am »
I've spent all day trying to solve this one myself, but I appear to lack the requisite knowledge. I've read the first 5 pages of this subforum and searched both here and extensively on stack and google, and dug through the tutorials and documentation. I'll give as much info as I know how to give and provide more on request.
So I have a piece of code that functions fine in an isolated project, but returns the following error when I close the window in the actual program.
Unhandled exception at 0x756ba4b9 in GameGraphics.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
I am running the latest SFML version, 2.3.2 (32) for VS2010,
Visual Studio pops up this extra frame titled crtexe.c
Call Stack looks like this:
GameGraphics.exe!_tmainCRTStartup() line 568
GameGraphics.exe!mainCRTStartup() Line 371
Contents of the crtexe.c frame look like this:
if ( !managedapp ) //value 0
exit(mainret);
//--> if (has_cctor == 0)
_cexit();
}
Autos window looks like this:
has_cctor (Value 0)
mainret (Value 0)
Linker->Input looks like this:
sfml-audio-d.lib
sfml-network-d.lib
sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib
All of the dlls from /bin are in the same directory as my executable. I have tried multiple downloads.
Minimum code sample:
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <string>
using namespace std;
class SFX {
private:
sf::Sound _sound;
sf::SoundBuffer _soundBuffer;
bool _initialized;
public:
void initialize(string fileName);
bool run();
SFX();
};
SFX::SFX() {
_initialized = false;
}
void SFX::initialize(string fileName) {
if(_soundBuffer.loadFromFile(fileName) ) {
_sound.setBuffer(_soundBuffer);
_initialized = true;
}
}
bool SFX::run() {
if( ! _initialized) {
//smartErr(__FUNCTION__,"NOT INITIALIZED");
return false;
}
//if(_sound.getStatus() == sf::Sound::Status::Playing) {
// return false;
//}
_sound.play();
return true;
}
class SoundService {
private:
public:
SFX sfxAttackBadMagic;
void initialize();
SoundService();
}soundServ;
SoundService::SoundService() {
}
void SoundService::initialize() {
sfxAttackBadMagic.initialize("Sounds/sfxAttackBadMagic.wav");
}
int main()
{
soundServ.initialize();
soundServ.sfxAttackBadMagic.run();
while(!sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
sf::sleep(sf::milliseconds(200));
}
return 0;
}
Notably, adding even this single line of code causes the same error:
sf::SoundBuffer testBuffer;
I've made all the changes and tried various changes, but nothing but removing the code solves the issue. Please help, you are my only hope.