SFML community forums

Help => General => Topic started by: bazik210 on February 07, 2019, 09:23:15 pm

Title: SoundBuffer sfml crash
Post by: bazik210 on February 07, 2019, 09:23:15 pm
When i'm trying to create SoundBuffer in class and use static linkage, it crashes. Tried also with unique_ptr, it returns emptiness... if soundmanager class created as non-global in main, seems problem dissapears.

SFML 2.5.1, vs17, win7 x64

In preproc:
WIN32
_DEBUG
_CONSOLE
SFML_STATIC
UNICODE

Used libs:
%(AdditionalDependencies)
sfml-audio-s-d.lib
sfml-graphics-s-d.lib
sfml-network-s-d.lib
sfml-window-s-d.lib
sfml-system-s-d.lib
openal32.lib
ws2_32.lib
gdi32.lib
opengl32.lib
flac.lib
freetype.lib
ogg.lib
vorbis.lib
vorbisenc.lib
vorbisfile.lib
winmm.lib

With dynamic linkage all fine, code was tested there before tries.
Title: Re: SoundBuffer sfml crash
Post by: eXpl0it3r on February 07, 2019, 11:07:05 pm
You can't use globally initialized SFML resources and you should avoid globals whenever you can.
Title: Re: SoundBuffer sfml crash
Post by: bazik210 on February 08, 2019, 02:33:49 am
Thanks for info, tried Singleton pattern, seems working for this.
Title: Re: SoundBuffer sfml crash
Post by: eXpl0it3r on February 08, 2019, 07:46:51 am
I would suggest dependency injection as the singleton pattern shouldn't be misused as "globale access" pattern.