On 29.01.2011, at 04:57, Anton Deguet wrote:

> I am using fltk from MacPort (fltk-devel @1.3.x-r7794_1) on Mac OS 10.6 and 
> my code doesn't work anymore.  It works on Linux, Windows and used to work on 
> Mac OS in the pre Cocoa era.  The symptom is a blank area where widgets 
> should be and the spinning beach ball.  Interestingly enough, I have an 
> example with an OpenGL window and this windows keeps being updated but the 
> widgets still don't show up.
> 
> I have no knowledge of Cocoa whatsoever so I hope this is not a hard 
> limitation ...

Haha, that's the idea with FLTK that you don't have to know a thing about your 
target.

> I did a bit of testing and it seems that the issue comes from the fact that 
> all my FLTK calls are performed in a separate thread, i.e. not the "main" 
> thread.   Is this possibly the cause of my problem?  If it is, is there a 
> known solution, ideally an Fl function usable on all OSs so the code remains 
> portable?  

You cant call any functions that create windows or call run, flush, wait, etc. 
from a thread. These functions need to be called from the main thread. Usually 
MSWindows is the platform that fails if you don't, but OS X does not like that 
either.

You can read all about this in the documentation under "Advanced: threading"

http://www.fltk.org/doc-1.3/advanced.html

To call anything FLTK from a thread (except the functions I mentioned above), 
call

Fl::lock();
someWidget->value(someValue);
someOtherWidget->color(FL_RED);
someOtherWidget->redraw();
Fl::unlock();
Fl::awake();
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to