Please read the FLTK guide on multithreading:
FLTK supports multiple platforms, some of them which do not allow any other but the main thread to handle system events and open or close windows. The safe thing to do is to adhere to the following rules for threads on all operating systems:
- Don't
show()
orhide()
anything that contains widgets derived from Fl_Window, including dialogs, file choosers, subwindows orFl_GL_Windows
Here is the FLTK-recommended way to handle GUI updates from a background thread:
The only workaround is to store what you want to do in static variables, call
fltk::awake()
, and make the main thread callfltk::wait()
repeatedly, checking and acting on the static values after each call.