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. DeleteLater vs. delete, possibly nested event loops and OS X
Forum Updated to NodeBB v4.3 + New Features

DeleteLater vs. delete, possibly nested event loops and OS X

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k 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.
  • R Offline
    R Offline
    RJVB
    wrote on last edited by
    #1

    Hello,

    I've gotten in a bit of a discussion when I submitted two KDE review reports for patch that seem to prevent a crash I was seeing in KDevelop, and that's based on http://qt-project.org/forums/viewthread/38406/#162801 .

    The latest of the reports is https://git.reviewboard.kde.org/r/120150

    My question is simple: should one use deleteLater to dispose of objects that correspond to a GUI element even when that element is not in use in other threads? Is that a (necessary) precaution on OS X only, or also on other OSes?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's generally good practice to let Qt's event loop handle the destruction of widgets. There might be some events still needing to be process (or in this case discarded) You might be deleting a parented widget which would be also destroyed because of it's parent being deleted right after you deleted that widget etc.

      Also, you can't use GUI elements in other threads. Only the main thread is available for that. However, you can update a widget through e.g. signals and slots.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RJVB
        wrote on last edited by
        #3

        As I thought, much like ObjC's retain/release scheme (which is like Qt's reference counting, except that it's also the main mechanism to handle object disposal).

        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