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

Author Topic: x64 - GetEvent crash  (Read 3385 times)

0 Members and 2 Guests are viewing this topic.

ronag

  • Newbie
  • *
  • Posts: 24
    • View Profile
x64 - GetEvent crash
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
x64 - GetEvent crash
« Reply #1 on: December 09, 2011, 10:33:43 pm »
I have no idea, sorry...
Laurent Gomila - SFML developer

ronag

  • Newbie
  • *
  • Posts: 24
    • View Profile
x64 - GetEvent crash
« Reply #2 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
x64 - GetEvent crash
« Reply #3 on: December 10, 2011, 10:04:13 am »
Thanks :)

But actually, it was fixed a long time ago in SFML 2.
Laurent Gomila - SFML developer

ronag

  • Newbie
  • *
  • Posts: 24
    • View Profile
x64 - GetEvent crash
« Reply #4 on: December 10, 2011, 02:44:11 pm »
Ah, I see.

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

 

anything