Important: Please read the Qt Code of Conduct -

Timers cannot be started from another thread

  • I have an app that draws on a canvas that is a QWindow. When the canvas needs a repaint because the data has changed, the canvas uses a separate thread to render to a QImage, and when complete the image is drawn to the QBackingStore.

    The canvas itself has a few timers (QTimer *) that are started and stopped in the canvas. They are not accessible from the thread at all.

    This all works well on Windows and Mac, however on Linux I am getting random crashes within the render code of the thread,; just before the crash there is a message like:

    QBasicTimer::start: Timers cannot be started from another thread

    In a run of ~150 gui tests this maybe happens 3-4 times, almost always on the same tests. If I run in debug mode I don't ever see a crash, only in release mode.

    Any clues as to what may be causing this? Thanks.

  • Lifetime Qt Champion

    Run your program with QT_FATAL_WARNINGS set (see in a debugger and see where it comes from. I would say accessing QBackingStore outside the main thread will be the cause - don't do that.

  • @Christian-Ehrlicher said in Timers cannot be started from another thread:


    Thank you, that was very useful - it helped debug the problem which was a crash in the thread code calling a signal handler, which tried to output a message to the gui... and so presumably caused the warnings.

    Fixing the crash eliminates the error messages and all working fine!

  • Lifetime Qt Champion

    @KeithS Nice to hear. Can you please mark the topic as solved then? Thx.

Log in to reply