I was able to isolate the bug, finally!
WORKING source:
#include <SFML/Graphics.hpp>
void ThreadFunc( void *arg ) {
sf::Context context;
}
int main() {
sf::RenderWindow window( sf::VideoMode( 800, 600, 32 ), "Context test" );
sf::Thread thread( ThreadFunc, 0 );
sf::Event event;
thread.Launch();
while( window.IsOpened() ) {
//window.GetEvent( event );
window.Clear();
window.Display();
}
thread.Wait();
return 0;
}
Compile that and you won't get any failures. Now, uncomment the line "window.GetEvent( event )" and start again: crashes.
A friend of mine pointed me to this page:
http://www.linuxquestions.org/questions/programming-9/xnextevent-select-409355/ . I think it's interesting that threading with X seems to be a mess. An Xlib resource can be only used once at a time, so maybe there lies the problem.
I really hope this can be solved. I'd do it myself, but I highly suck at X programming.
Edit:By the way, this is a backtrace I was able to get:
#12 0x00007fc8d6edfd88 in XRRGetScreenInfo () from /usr/lib/libXrandr.so.2
#13 0x00007fc8d847248a in sf::priv::VideoModeSupport::GetDesktopVideoMode () from /usr/lib/libsfml-window.so.2.0
#14 0x00007fc8d846d8a9 in sf::VideoMode::GetDesktopMode () from /usr/lib/libsfml-window.so.2.0
#15 0x00007fc8d84717af in sf::priv::ContextGLX::ContextGLX () from /usr/lib/libsfml-window.so.2.0
#16 0x00007fc8d846d0da in sf::priv::ContextGL::New () from /usr/lib/libsfml-window.so.2.0
#17 0x00007fc8d846cd19 in sf::Context::Context () from /usr/lib/libsfml-window.so.2.0
#18 0x000000000040108f in ThreadFunc (arg=0x0) at context.cpp:4
Could it be possible that by using GetEvent() and creating the Context the screen you fetch in GetDesktopVideoMode() is used twice?