Hi all,
in my application, a window holds a custom widget (derived from Fl_Box) where
I overloaded the draw() method to display things. So far, so good.
class MyWidget: public Fl_Box {
// ..... constructor and stuff
// just draws a frame for tests, called by 'the System'
virtual void draw();
// draws something that depends on time, called by a pthread
virtual void drawAnimated(int time);
};
Now I want to draw something (consisting of simple lines and shapes)
that changes every 100ms or so and I planned to use a thread that
calls a method which draws something depending on a givem parameter.
(in the example above it's drawAnimated(time) ).
Here's the thread-function (partially):
void* tFunc(void*) {
while (true) {
int time = // get time somehow....
Fl::lock();
// 'widget' is a global and valid pointer
// to my custom widget
widget->drawAnimated(time);
Fl::unlock();
}
}
In main() i called Fl::lock() and I started the thread using the threads.h
in the test/ folder of the fltk source-directory:
Fl_Thread myThread;
fl_create_thread(myThread,tFunc,0);
At the end of main, after creating all necessary things and open
the main window that contains my widget, I do that:
while(win->shown()) Fl::wait();
Unfortunately, my applicaton crashes and I dont know what I am
doing wrong here :-( It works when I dont call 'drawAnimated()' in
the thread, but then it becomes useless :-(
Can someone help me here?
Martin
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk