Thursday, October 22, 2009

wxWidgets and Failed Assertions

I was writing my first GUI in C++ on linux using wxwidgets and would erratically get this message:

./../src/xcb_lock.c:33: _XCBUnlockDisplay: Assertion `xcb_get_request_sent(dpy->xcb->connection) == dpy->request' failed

it did take a couple different forms (i think there was one other), but usually had a dpy->request in it and xcb_lock.c), but this one came up quite often. it was very erratic, and would sometimes keep my gui from coming up at all.

I ultimately (thanks to the help of people in #wxWidgets on freenode) figured out it was because wxWidgets is not thread safe and my worker thread was calling member functions of my GUI.

To fix this I added wxMutexGuiEnter() and wxMutexGuiExit() around my code that access the gui and all issues were resolved.

No comments: