Thank you Ian for your response. 

I removed the fl_line(...) from the thread. Now I just prepare the scene
(a dummy object that just represents a line).

The crash is gone. But, the widget never gets redrawn untill I e.g.
resize the window. The thread calls Fl::awake() but that does not
update the widget and the draw-method is not called. Here's the thread:
(explanation after the code)

void* stepperFunc(void* p) {
  while(true) {
    if(view) {
      Object o; // holds some floats
      o.xdist = 800*std::sin(ycoord/57.0f); // ycoord is an int
      Fl::lock();
      app->objectList.add(o); // objects on that list get drawn
      Fl::unlock();
      Fl::awake((void*)view); // view is an instance of my widget
      if(ycoord>=400) ycoord = 0;
      ycoord+=5;
      usleep(1000*100);
      std::cerr << o.xdist << std::endl;
    }
  }
}

The object 'o' just has a value 'xdist' that waves with 
an amplitude of 800. This x-value is used to draw an
animated line. It works, when I resize the window, so I
have only the problem that the thread does not force
a redraw of my widget.


MacArthur, Ian (SELEX) (UK), wrote:
> So... Really, what you need is for your worker thread to compute the
> details of the new scene, and store it somewhere, then call awake() from
> the worker thread.
> The widgets draw method will then (or very soon after) be called by the
> main thread, and it should then read and interpret the scene details
> generated by the worker thread...


Martin

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

Reply via email to