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. How to ensure an object is deleted via deleteLater() before the event loop ended?
Forum Updated to NodeBB v4.3 + New Features

How to ensure an object is deleted via deleteLater() before the event loop ended?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 686 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.
  • jronaldJ Offline
    jronaldJ Offline
    jronald
    wrote on last edited by
    #1

    In a thread:

    someObject->deleteLater();
    exit();
    

    How to ensure someObject is deleted before the event loop ended?

    raven-worxR 1 Reply Last reply
    0
    • jronaldJ jronald

      In a thread:

      someObject->deleteLater();
      exit();
      

      How to ensure someObject is deleted before the event loop ended?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @jronald
      doesn't make sende to use deleteLater() then.
      In such case you can use delete actually.

      You could force the events to be processed by the QApplication instance, but this raises the chance for side-effects and should by all means be avoided.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      jronaldJ 1 Reply Last reply
      2
      • raven-worxR raven-worx

        @jronald
        doesn't make sende to use deleteLater() then.
        In such case you can use delete actually.

        You could force the events to be processed by the QApplication instance, but this raises the chance for side-effects and should by all means be avoided.

        jronaldJ Offline
        jronaldJ Offline
        jronald
        wrote on last edited by
        #3

        @raven-worx
        delete directly is ok, however delete in a event driven way also makes sense, I did it this way:

        connect(networkReply, &QNetworkReply::destroyed, this, &QThread::quit);
        

        By far delete directly is more efficient and not too complex, but the event driven ways is more general.

        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