Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Timers cannot be started from another thread
Forum Updated to NodeBB v4.3 + New Features

Timers cannot be started from another thread

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 374 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KeithS
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Run your program with QT_FATAL_WARNINGS set (see https://doc.qt.io/qt-5/debug.html) 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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • K Offline
        K Offline
        KeithS
        wrote on last edited by
        #3

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

        QT_FATAL_WARNINGS

        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!

        Christian EhrlicherC 1 Reply Last reply
        4
        • K KeithS

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

          QT_FATAL_WARNINGS

          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!

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved