SFML community forums

Help => Window => Topic started by: ronag on December 09, 2011, 10:20:18 pm

Title: x64 - GetEvent crash
Post by: ronag on December 09, 2011, 10:20:18 pm
I have an application that works well in 32 bit, however I'm having some problems with 64 bit.

The GetEvent method seems to crash my application.

I have compiled SFML 1.6 as a static library for x64 with /MDd.

I have traced the problem down to the very first call of GetEvent and then deeper into the code:

Code: [Select]
void WindowImplWin32::ProcessEvents()
{
    // We update the window only if we own it
    if (!myCallback)
    {
        MSG Message;
        while (PeekMessage(&Message, NULL, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&Message);
            DispatchMessage(&Message); // access-violation
        }
    }
}


Where Message has the following values:

message = 799
wParam = 1
lParam = 0
time = 25335545
pt = {x=611, y=411}

Any ideas what could cause this our how to debug it?

If I just skip the GetEvent calls the application runs fine and the window is rendered, but it of course wont respond to any interaction.

EDIT:

On second thought this should proably go into the "Window" forum.
Title: x64 - GetEvent crash
Post by: Laurent on December 09, 2011, 10:33:43 pm
I have no idea, sorry...
Title: x64 - GetEvent crash
Post by: ronag on December 09, 2011, 11:26:15 pm
Hey Laurent.

I found the problem

In WindowImplWin32.cpp

Code: [Select]
       // Get WindowImplWin32 instance (it was passed as the last argument of CreateWindow)
        longThis = reinterpret_cast<long>(reinterpret_cast<CREATESTRUCT*>(LParam)->lpCreateParams);


That is wrong, since long is 32 bit on x64 but pointers are 64 bit.

You should change it to:

 
Code: [Select]
      LONG_PTR This = reinterpret_cast<LONG_PTR>(reinterpret_cast<CREATESTRUCT*>(LParam)->lpCreateParams);

After changing this it works fine.

I noticed this problem migth occur in a few other places, e.g. the first constructor. with SetWindowLongPtr?
Title: x64 - GetEvent crash
Post by: Laurent on December 10, 2011, 10:04:13 am
Thanks :)

But actually, it was fixed a long time ago in SFML 2.
Title: x64 - GetEvent crash
Post by: ronag on December 10, 2011, 02:44:11 pm
Ah, I see.

Well I guess I rly should start to upgrade to SFML 2 soon.