SFML community forums

Help => Window => Topic started by: lolz123 on September 05, 2010, 04:17:07 pm

Title: Memory Access Violation After Calling App.Close();
Post by: lolz123 on September 05, 2010, 04:17:07 pm
Hello,

I am new to SFML (just switched over from SDL) and programming in general, so this might be a pretty stupid question, but here it goes:

I tried code from the Window Events as well as the Window Creation tutorials, but while running either of them I get:

Code: [Select]
Unhandled exception at 0x6903a39d in ThingThingSFML.exe: 0xC0000005: Access violation reading location 0x00000054.

I narrowed down the code to:

Code: [Select]
#include <SFML/Window.hpp>

int main()
{
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");
App.Close();

    return EXIT_SUCCESS;
}


yet I still get the same error. It opens a window perfectly, but it gets a memory access violation when Close(); is called. All other examples that do not use the Window class seem to work fine. I was using SFML2.0, so I tried the same with SFML1.6 with no luck (same error)

Compiler: VS2010

I linked to the dynamic versions of the libraries. I tried using sfml-main as well, I can't see how that could possibly make a difference anyways.

What could possibly cause this error?

Thank you for any help you can offer!
Title: Memory Access Violation After Calling App.Close();
Post by: Laurent on September 05, 2010, 07:22:35 pm
Remember to link to the debug libraries (with -d suffix) when you compile in debug mode.
Title: Memory Access Violation After Calling App.Close();
Post by: lolz123 on September 05, 2010, 07:29:07 pm
I did that, I tried it on both debug and release modes. Both give the same error. Like I said, it runs, but it dies on Close();

Debug:

sfml-main-d.lib
sfml-window-d.lib

Release:

sfml-main.lib
sfml-window.lib

All of the DLL's are in the project folder, and I defines the SFML_DYNAMIC macro under Preprocessor.
Title: Memory Access Violation After Calling App.Close();
Post by: Laurent on September 05, 2010, 07:32:27 pm
Do you have an ATI graphics card?
Title: Memory Access Violation After Calling App.Close();
Post by: lolz123 on September 05, 2010, 07:41:53 pm
Yes, I do.
Title: Memory Access Violation After Calling App.Close();
Post by: Laurent on September 05, 2010, 08:30:54 pm
Ok, so it's a known bug that I have to fix.
Title: Memory Access Violation After Calling App.Close();
Post by: lolz123 on September 26, 2010, 03:21:52 pm
I discovered that the access violation actually comes from the window's destructor, not Close(); after attempting to get this to work again after some time.
Title: Memory Access Violation After Calling App.Close();
Post by: OniLinkPlus on September 26, 2010, 10:09:49 pm
You're using Visual Studio 2010, so you need to recompile SFML from source.
Title: Memory Access Violation After Calling App.Close();
Post by: lolz123 on September 27, 2010, 03:02:18 am
I did, I am using SFML2 so I was sort of forced to anyways. I just opened the VC2008 project and VC2010 automatically converted it allowing me to recompile it for 2010 (I generated both both debug and release versions). To make certain I was using the correct .dll's, I checked their "last edited" dates and saw they were the same as the time I recompiled it. Everything else in SFML runs except the windows destructor.