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

Author Topic: SoundBuffer sfml crash  (Read 1246 times)

0 Members and 1 Guest are viewing this topic.

bazik210

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
SoundBuffer sfml crash
« 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.
« Last Edit: February 07, 2019, 09:28:05 pm by bazik210 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SoundBuffer sfml crash
« Reply #1 on: February 07, 2019, 11:07:05 pm »
You can't use globally initialized SFML resources and you should avoid globals whenever you can.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

bazik210

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: SoundBuffer sfml crash
« Reply #2 on: February 08, 2019, 02:33:49 am »
Thanks for info, tried Singleton pattern, seems working for this.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SoundBuffer sfml crash
« Reply #3 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything