Hello!
I have a problem when using sf::Clipboard::getString(). I'm calling it every frame, to sync the clipbaord of the X-server with an internal clipboard. It works fine for a while, but crashes after a small amount of time (usually 5 seconds to more than 60 seconds). When it crashes I get one of two error messages that occur:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
MyApp: xcb_io.c:259: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
OR
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
after 5340 requests (5340 known processed) with 0 events remaining.
After some investigation I found that the first error happens during a call for XNextEvent in the SFML code
String ClipboardImpl::getString()
{
if(!is_init)
initClipboard();
if(is_fail || is_host)
return string;
// Dangerous! Wipes all previous events!
XSync(display, true);
XConvertSelection(display, selection, utf8_text, atom_text, window, CurrentTime);
XEvent event;
pthread_mutex_lock(&mutex);
XNextEvent(display, &event); //<-- Crashes here when getting the first listed error message.
pthread_mutex_unlock(&mutex);
...
When calling the clipboard in my code, I simply do:
string osStr = "";
sf::String osSfStr = sf::Clipboard::getString();
osStr = osSfStr;
This code is called inside a update sequence with a lot of other things.
I have a suspicion that the error happens due to the multi-threading process in sf::Clipboard, but I don't know for sure.
My system information:
OS: Manjaro 17.1.10 Hakoila
Kernel: x86_64 Linux 4.9.96-1-MANJARO
GCC-version: 7.3.0
I'm really hyped for the clipboard functionality, and it works great before it crashes. If you have any tips, I'd be glad to hear. Otherwise, I hope this helps finding the error
For now I'm implementing a temporary Clipboard class to get clipboard text from the X-server.
- Robin.