简体   繁体   中英

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();

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().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM