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. Does closing a QProcess detach it from QSharedMemory it was attached to?

Does closing a QProcess detach it from QSharedMemory it was attached to?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 657 Views
  • 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
    fugreh
    wrote on last edited by
    #1
    1. I create a QSharedMemory instance in the main application.
    2. I then create and start a QProcess and wait for it to finish (or time out) in the main application thread
    3. The created process attaches to the QSharedMemory instance and starts doing some computation

    The process then updates the main application on its progress via readyRead(). A progress dialog is being displayed to the user and if they press Cancel, then the process is closed using subProcess->close().

    My question is: Since the child process is killed, is it automatically detached from the QSharedMemory it attached to? Or since it did not detach properly (via QSharedMemory's destructor for example) would there be a memory leak?

    Thanks.

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

      The documentation is imo very clear about this: http://doc.qt.io/qt-5/qsharedmemory.html#details

      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
      3
      • F Offline
        F Offline
        fugreh
        wrote on last edited by
        #3

        Yes, you are right it is very clear, I should have looked more carefully. Thanks.

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved