Hi there,

in an application of mine I have two threads:
1. The main GUI thread and
2. A worker thread
The  worker thread is created with the boost thread library and does its
job in general pretty well.
Now I need to listen for a keystroke in the worker thread. Up to now I
was using the following function for this:
bool key_pressed = fltk::get_key_state(m_keyForward); // m_keyForward is
the key to look for
If the key is pressed the worker thread should react on this. Everything
works fine in windows, but in linux I get the following error:
> X I/O error
... and then the application closes. This error occus directly at the
call, no key has to be pressed.

Today I read about multithreading support in fltk 2 online:
http://www.fltk.org/doc-2.0/html/group__multithreading.html
I added fltk::lock() right at the beginning of the main function and now
the feedback to a key press is:
> X I/O error
> pure virtual method called
> terminate called without an active exception
This error appears not always, it happens that only the "X I/O error"
appears.

If I now add fltk::lock() and fltk::unlock() around the get_key_state()
call (and thus include <fltk/run.h>) the error disappears, but I can't
get a display redraw anymore. Even if I put fltk::redraw() and
fltk::awake() right before fltk::unlock(). In fact, the application
seems to hang in general, like the main thread does not get activated
anymore.

Do you have an idea what I could be doing wrong or do you know if I am
on the correct path    ?

Thanks in advance,
Tom

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to