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 stopped from a different thread
Forum Updated to NodeBB v4.3 + New Features

timers cannot be stopped from a different thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 1.2k Views 1 Watching
  • 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.
  • H Offline
    H Offline
    HJPE
    wrote on last edited by
    #1

    My application uses a Qt GUI loaded at runtime from a dynamic library. When loading, I do the following:

    1. Create a dedicated thread for Qt. The points 2) -5) all happen within this thread!!!
    2. Allocate the QApplication object
    3. Call QQmlComponent::create
    4. Call QApplication::exit
    5. Delete the QApplication object
    6. Stop the Qt thread
    7. Shut down my application. The last log output I see then is: QObject::~QObject: Timers cannot be stopped from another thread.

    That is not nice, but what is really bothering me, is that some shutdown code of a dll I am using is not executed anymore. This is not happening if I do not load the library containing the Qt code. I would assume, that after point 6), there is no Qt object anymore, so why do I see this message?
    As I said, I have been very careful to do everything in the qtmain (not application main) thread. How can I find out, what is causing this?

    One thing: when using QQmlComponent, I am also using QQmlEngine::setObjectOwnership with QQmlEngine::CppOwnership, but removing this does not change the situation. This function is not documented sufficiently, I only use it because of the sample code I based my code on.

    Many thanks

    JKSHJ 1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      You run Qt in another process, not in another thread.

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

        Run your app with a debugger and a set env var QT_FATAL_WARNINGS

        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
        • H HJPE

          My application uses a Qt GUI loaded at runtime from a dynamic library. When loading, I do the following:

          1. Create a dedicated thread for Qt. The points 2) -5) all happen within this thread!!!
          2. Allocate the QApplication object
          3. Call QQmlComponent::create
          4. Call QApplication::exit
          5. Delete the QApplication object
          6. Stop the Qt thread
          7. Shut down my application. The last log output I see then is: QObject::~QObject: Timers cannot be stopped from another thread.

          That is not nice, but what is really bothering me, is that some shutdown code of a dll I am using is not executed anymore. This is not happening if I do not load the library containing the Qt code. I would assume, that after point 6), there is no Qt object anymore, so why do I see this message?
          As I said, I have been very careful to do everything in the qtmain (not application main) thread. How can I find out, what is causing this?

          One thing: when using QQmlComponent, I am also using QQmlEngine::setObjectOwnership with QQmlEngine::CppOwnership, but removing this does not change the situation. This function is not documented sufficiently, I only use it because of the sample code I based my code on.

          Many thanks

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @HJPE said in timers cannot be stopped from a different thread:

          I would assume, that after point 6), there is no Qt object anymore, so why do I see this message?

          Unfortunately, there exists a global static QObject that you cannot delete. This is a known issue when you initialize Qt in a secondary thread: https://lists.qt-project.org/pipermail/development/2021-May/041517.html

          You can safely ignore the Timer message.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          H 1 Reply Last reply
          2
          • JKSHJ JKSH

            @HJPE said in timers cannot be stopped from a different thread:

            I would assume, that after point 6), there is no Qt object anymore, so why do I see this message?

            Unfortunately, there exists a global static QObject that you cannot delete. This is a known issue when you initialize Qt in a secondary thread: https://lists.qt-project.org/pipermail/development/2021-May/041517.html

            You can safely ignore the Timer message.

            H Offline
            H Offline
            HJPE
            wrote on last edited by
            #5

            @JKSH I skipped two points in my list:
            Before point 1), I load the dll which implicitly depends on Qt. The loading executable has no such dependency.
            Before point 7), I unload this dll. So, all Qt related stuff should be unloaded as well. I would expect the warning to be issued at this occasion, not when the main process stops, which can be hours later.

            I still have to make 100% sure though, that the dll is really, really unloaded. I will give more feedback when done so.

            S 1 Reply Last reply
            0
            • H HJPE

              @JKSH I skipped two points in my list:
              Before point 1), I load the dll which implicitly depends on Qt. The loading executable has no such dependency.
              Before point 7), I unload this dll. So, all Qt related stuff should be unloaded as well. I would expect the warning to be issued at this occasion, not when the main process stops, which can be hours later.

              I still have to make 100% sure though, that the dll is really, really unloaded. I will give more feedback when done so.

              S Offline
              S Offline
              SpringRoach
              Banned
              wrote on last edited by SpringRoach
              #6
              This post is deleted!
              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