3

I'm using sf::Threads in my program and I have it running in windows, but now I'm porting it over to windows. I already have the build target made and it successfully compiles, and runs right up until I try to launch the game, which uses threads. Then my objects are successfully constructed, but then it says that:

[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
NumberHunterGame: xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.

I'm using SFML 2.1 in my program grabbed directly from the Fedora repos. I was reading a forum thread about passing my sf::RenderWindow as a pointer to my rendering thread func, but I don't think that will make any difference as I made my sf::RenderWindow instance a global. I tried calling XInitThreads() at the beginning of main, but that causes more problems then it solves. The whole file is available here: https://github.com/HSchmale16/NumberHunterGame/blob/master/main.cpp

Edit: I've been asked about how I have the threads set up and this is the general design. I create the sf::RenderWindow in the main thread then deactivate in the main thread then launch the rendering thread. After that I launch the game event handling thread. The only thing the main thread handles is the window events, so it should be thread safe. The SFML docs say that I can handle the window events in the main thread while using another thread to render.

HSchmale
  • 1,838
  • 2
  • 21
  • 48
  • Are you trying to have more than one thread modify SFML objects? That's not safe. – Collin Dauphinee Feb 27 '15 at 02:27
  • What do you mean by 'causes more problems than it solves'? Have you seen http://stackoverflow.com/questions/23585435/cannot-call-xinitthreads – Prismatic Feb 27 '15 at 02:31
  • @CollinDauphinee I just added the general design of who I have threading handled in my program to my question. – HSchmale Feb 27 '15 at 02:31
  • @Pris When I add `XInitThreads()` to the start of my program it causes, an error in the SFML header `WindowStyle.hpp` saying that it needs a numeric constant, that's why it causes more problems. I don't want to edit the library files or mess with my window creation, as that might ruin compatibility with windows. – HSchmale Feb 27 '15 at 02:35
  • 1
    xcb is telling you to call XInitThreads. Doing that may not be optional. If that causes an error when you compile, fix that error. You can isolate platform specific code by using #ifdefs – Prismatic Feb 27 '15 at 02:40
  • @Pris I have no idea what the compiler error is telling me to fix, because once I add `XInitThreads()`, it complains about the declaration of the SFML window style enumeration. – HSchmale Feb 27 '15 at 02:42
  • @Pris I tried using `XInitThreads()` and it causes an assertion to fail, so what do I do? – HSchmale Feb 28 '15 at 01:45
  • You realize your descriptions are extremely vague and hard to follow right? First you have a problem with some enumeration, now you have an assertion. None of this information is specific enough for anyone that isn't you to understand what's going on. Post the errors properly and be descriptive. You might also consider trying to come up with a minimal example to recreate the problem. See http://sscce.org/ for example. – Prismatic Feb 28 '15 at 02:09
  • These are known problem for SFML. Use instead std::thread, which is more good. – AlexxanderX Feb 28 '15 at 09:04

0 Answers0