95xxxtent
95xxxtent

Reputation: 21

FLTK Window freezing inconsistently

I am trying to simululate "real time" movement of widgets in a window thus the use of the flush method, and basically during this while loop Fl Window will freeze at a random point in the loop, but not every time that the code is run, more like once in 3 times. The window would get Not responding error, and then recover after the loop has finished.

As shown in the code, I tried using lock function thinking that it was the main module trying to interfere, but it yielded no results

Fl::lock();
while (instructions.size() > 0) {
    instructions[0]->do_it();
    this->redraw();
    Sleep(plotSpeed);
    Fl::flush();
    instructions.erase(instructions.begin());
}
Fl::awake();
Fl::unlock();

Upvotes: 0

Views: 227

Answers (1)

Pal Szasz
Pal Szasz

Reputation: 3225

I also had issues with this, mostly the behavior was different on OSX and Linux. But one suggestion: after the Sleep call, also add an Fl::check() call, which should handle all pending internal messages. Alternatively try Fl::wait().

Upvotes: 0

Related Questions