On 20 Jun 2012, at 20:32, William wrote:
>> Hello, I'm fairly new to FLTK but I am having some trouble getting a
>> Fl_Valuator to update from a callback. I currently have the following
>> callback on a button:
>>
>> {
>> boost::thread t(boost::bind(&MotorControl::Sweep, motor_control));
>> }
>>
>> This should call the MotorControl::Sweep method in a separate thread.
>> Within this method I issue the value(int) method on a few Fl_Valuators to
>> change their values. There is also a boost sleep command between these
>> method calls.
>>
>> My issue is if I do not move the mouse, the Fl_Valuators (which are
>> horizontal sliders) do not update their positions. When I do move the
>> mouse, the sliders instantly jump to their correct values.
>>
>> How can I get the "Fl_Value_Slider"s to update correctly without me moving
>> the mouse?
>>
>> Thank you!
>
>
> I found a solution that seems to work. Calling Fl::check(); after setting
> with value(int) does the trick.
Actually, that is almost certainly the wrong way to go - see Matthias' post...
You need to read the manual (section 10 of the fltk-1.1 manual, or the
"Advanced FLTK" section of the fltk-1.3 manual) and follow some of the recipes
suggested there.
In summary though, calling Fl::check() from any thread other than the "main"
thread is likely to croak in odd ways at some point (how and when is platform
dependent!) so you need to us Fl::awake() instead, and you really do want to
Fl::lock() and unlock() any widget accesses from the worker threads.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk