SFML community forums

Help => Graphics => Topic started by: EldarFara on May 06, 2018, 06:19:40 pm

Title: Access violation when declaring Texture object
Post by: EldarFara on May 06, 2018, 06:19:40 pm
Hello, I have strange problem while trying to declare Texture object inside class.
What I have:
(click to show/hide)
That supposed to be a menu class that declaring images, textures and sprites for menu and draws it, and i have "Unhandled exception at 0x779522E2 (ntdll.dll) in Project137.exe: 0xC0000005: Access violation writing location 0x00000004." on the line where system_main_menu object is being declared.
Problem solves only if I will remove that 3 lines with declaring textures: Texture t_main_logo, Texture t_main_menu_background and Texture t_welcome_to_loading and usage of them.
For example this code won't work:
(click to show/hide)
It works if I declare texture outside class (in main() for example) but still doesnt work if I declare them in any other class.
Strange thing is that code worked fine until I started to use cout to get some variables values, then that error appeared, and when I used ctrl+z to undo code I wrote that problem didn't disappear. I'm not sure if this problem connected to SFML itself (probably my software problem) but I googled that problem I have and found out they all have very different reasons. Sorry if provided not enough info about problem, feel free to ask for more.
I use SFML 2.4.2 x32 in VS 2017, precompiled build by Nightlybuilds (here (https://nightlybuilds.ch/project/show/1/SFML/)).
Title: Re: Access violation when declaring Texture object
Post by: eXpl0it3r on May 06, 2018, 06:23:54 pm
Did you also download the 32bit binaries and are you certain you're using the 32bit compiler?

If you use the debugger, where does it crash exactly?
Title: Re: Access violation when declaring Texture object
Post by: EldarFara on May 06, 2018, 06:47:18 pm
Many thanks for fast answer,
I use 32bit binaries and x86 compiler (in case if you meant it).
Not sure about what debugger you meant, I compile in debug mode, it builds the program and opens debug console but not the SFML window, and pointing to exception in line with declaring object of class with textures, as I described.
Title: Re: Access violation when declaring Texture object
Post by: eXpl0it3r on May 06, 2018, 10:07:48 pm
What's the callstack? (If you don't know what that is, you may want to look it up :) )
Title: Re: Access violation when declaring Texture object
Post by: EldarFara on May 07, 2018, 01:10:52 pm
Good day,
Here is my callstack:
(click to show/hide)
Title: Re: Access violation when declaring Texture object
Post by: EldarFara on May 10, 2018, 10:19:23 am
After discussing the the topic in SFML discord group it turned out that using another precompiled SFML binaries helps. So problem is solved for now