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. destroyed while one of its QML signal handlers is in progress
Qt 6.11 is out! See what's new in the release blog

destroyed while one of its QML signal handlers is in progress

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 3.0k 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.
  • mmjvoxM Offline
    mmjvoxM Offline
    mmjvox
    wrote on last edited by
    #1

    I have a StackView in my project and sometimes i push a new page or pop a page from that ... and it is working normally and fine.

    but sometimes in some pages i call a non return function (void) a from a c++ class (i defined it in public slots part in header) ... when i poping that page, if the function is not finished yet whole of the app crashes and write this error in output console:

    destroyed while one of its QML signal handlers is in progress.
    Most likely the object was deleted synchronously (use QObject::deleteLater() instead), or the application is running a nested event loop.
    This behavior is NOT supported!
    qrc:/Posts.qml:387: function() { [native code] }
    

    What's wrong with me?

    1 Reply Last reply
    1
    • mmjvoxM Offline
      mmjvoxM Offline
      mmjvox
      wrote on last edited by mmjvox
      #2

      finaly I fixed it myself:
      we can call function from another function with

      QMetaObject::invokeMethod
      

      In this way, qml item no longer waits for the cpp function to end,
      for example:

      void MyClass::functionA(QString url,QString allParams)
      {
          QMetaObject::invokeMethod( this, "functionAـreal",Qt::QueuedConnection, Q_ARG( QString, url ), Q_ARG( QString, allParams ));
      }
      
      void MyClass::functionAـreal(QString url,QString allParams)
      {
      .............. Things that take longer
      }
      
      1 Reply Last reply
      0
      • L Offline
        L Offline
        lotfollah
        wrote on last edited by
        #3

        Had the same issue, and used your solution to solve the problem. Thanks.

        One thing that worth mentioning here is that if you use QMetaObject::invokeMethod to run a method, you should declare that method as a slot in your class definition for it to work.

        1 Reply Last reply
        1
        • R Offline
          R Offline
          RORONOA
          wrote on last edited by
          #4

          Worked for me perfectly too.

          @lotfollah thanks for mentioning that the function that should be used with QMetaObject should be a slot.

          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