SFML community forums

Help => Window => Topic started by: tntexplosivesltd on May 09, 2011, 02:39:21 am

Title: X error on program exit
Post by: tntexplosivesltd on May 09, 2011, 02:39:21 am
Hmm. I'm using Arch on a netbook (the Acer Aspire One D255), and when I close my program I get the following error:
Code: [Select]

X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  137 (DRI2)
  Minor opcode of failed request:  7 (DRI2GetBuffersWithFormat )
  Resource id in failed request:  0x2200006
  Serial number of failed request:  187
  Current serial number in output stream:  187

Is this the code's fault, or is it xf86-video-intel's fault?
Thanks
Title: X error on program exit
Post by: Laurent on May 09, 2011, 07:53:57 am
It's most likely a driver bug.
Title: Re: X error on program exit
Post by: Gallaecio on May 18, 2012, 08:22:30 pm
I run into this, and found out how to solve it. It was quite simple, actually.

I was doing this:

while (window.IsOpened())
{
  sf::Event event;
  while(window.GetEvent(event))
  {
    // Window-broad event handling.
    if (event.Type == sf::Event::Closed)  window.Close();
    // [More event handling]
  }

  // [OpenGL Rendering]
  window.Display();
}

Now, I am doing this instead:

while (window.IsOpened())
{
  // [OpenGL Rendering]
  window.Display();

  sf::Event event;
  while(window.GetEvent(event))
  {
    // Window-broad event handling.
    if (event.Type == sf::Event::Closed)  { window.Close(); break; }
    // [More event handling]
  }
}

Before, I was closing the window and later calling window.Display(), which I guess was triggering the error. Now, upon close action on the user side, I close the window, break the event handling (any additional event will not matter since the application is being closed), and since the event handling is now at the end of the loop, there is no further call to window.Display().

Now the output is clean when leaving the application :)
Title: Re: X error on program exit
Post by: Laurent on May 18, 2012, 08:24:22 pm
sf::Window's functions are safe when the window has been closed. The error most likely came from your OpenGL calls.