Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] Thread safety with deletion of dynamically created components
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Thread safety with deletion of dynamically created components

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.4k 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.
  • F Offline
    F Offline
    frankiefrank
    wrote on last edited by
    #1

    I have dynamically created QML components to read user input in various ways. I iterate through them in the main QML rectangle to query some changed properties. This is done with a javascript loop checking the children of the main container. I now want to allow the user to close (and destroy) these components by using a destroy() call when clicking on a close button inside them.

    How can I ensure that this is safe and I'm not trying to access a component that is being destroyed while iterating through my loop in the main QML rectangle?

    "Roads? Where we're going, we don't need roads."

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      The loop in your QML is actually still in the main thread. All GUI elements have to live in the main thread (QML or otherwise) so there shouldn't be any threading issue at all.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        frankiefrank
        wrote on last edited by
        #3

        Thanks for your response. I can sleep at night :)

        "Roads? Where we're going, we don't need roads."

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          No problem! Sleep well!

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          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