First, these are not compile errors - they are X server runtime warnings that come from incorrect manipulation of X server resources (like widgets).
The problems you experience are caused by the other part of the code even if they are revealed only when you use the code you posted. My very very long shot is that you try to manipulate widgets from within a worker thread, but without seeing the code, I can't say more.
BTW. Using fork() in Qt apps is not a very good idea - it's probably what causes you problems.
Bookmarks