On 18 Mar 2012, at 08:28, Adam wrote:

> You make a good point about threading Mike.  The code I posted up was a part 
> of the server connect thread.
> 
> Now the whole GUI breaks.  Whenever the server isn't running and the server 
> connect thread would change the status from nothing to "Connecting" to 
> "Unconnected - Unvalidated" and the thread exits everything is fine.  But 
> then I start the server and it goes from nothing to "Connecting" to 
> "Connected - Validated" or "Connected - Unvalidated" and suddenly it breaks 
> the whole GUI.  Each time its in a different way like stray lines or missing 
> text or twice as much text as there is supposed to be.  Commenting out all 
> the status updates except Connecting fixes the issue.  I guess I'll post up 
> the whole thread and see what y'all can see.

I'm not seeing anything obviously broken in the code you posted, but...

You say "server connect thread" in a few places - should I take that to mean 
that this code is running in a thread context that is *not* the main() thread 
context?

If so, that'll likely not work right. To get fltk to play nice with threads in 
Windows you need to:

a) Run the fltk GUI in the main thread and call Fl::lock() exactly once in the 
main thread just before you show your first window. No other 
Fl::lock()/unlock() calls should occur in the main thread (the fltk runtime 
will handle locking in the main thread automatically if you wake it up by 
calling Fl::lock() that first time!)

b) ensure that any GUI updates from child threads (i.e. non-main threads) are 
wrapped by Fl::lock() and Fl::unlock() calls. Also, never call Fl::check() from 
a child thread - use Fl::awake() instead.


The symptoms of getting this wrong vary depending on circumstance, but the 
things you describe might well be caused by this...

I think the "Advanced Topics" part of the fltk docs talks about this.



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

Reply via email to