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. Clear QSharedMemory after crash
Qt 6.11 is out! See what's new in the release blog

Clear QSharedMemory after crash

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.3k 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.
  • dporobicD Offline
    dporobicD Offline
    dporobic
    wrote on last edited by
    #1

    Re: QT single instance application

    Hello, I'm trying to implement a SingleInstance Solution for my application and have used the solution mentioned in the above topic (solution proposed by @SGaist ). Works fine as long as we don't run into any crash. In case of a crash, the destructor is not called and an entry is left in the SharedMemory causing the first started instance after a crash to think that there is already a running instance.

    Is there a way to mitigate this issue? I'm working on a cross platform application so I'm looking for a solution that would work on Windows, Linux and MacOS

    https://github.com/ksnip/ksnip

    JonBJ 1 Reply Last reply
    0
    • dporobicD dporobic

      Re: QT single instance application

      Hello, I'm trying to implement a SingleInstance Solution for my application and have used the solution mentioned in the above topic (solution proposed by @SGaist ). Works fine as long as we don't run into any crash. In case of a crash, the destructor is not called and an entry is left in the SharedMemory causing the first started instance after a crash to think that there is already a running instance.

      Is there a way to mitigate this issue? I'm working on a cross platform application so I'm looking for a solution that would work on Windows, Linux and MacOS

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @dporobic
      I have not looked at the code you are using from singleton instance, but you might read the accepted solution to https://stackoverflow.com/questions/42549904/qsharedmemory-is-not-getting-deleted-on-application-crash.

      dporobicD 1 Reply Last reply
      0
      • dporobicD Offline
        dporobicD Offline
        dporobic
        wrote on last edited by
        #3

        @JonB Thanks, will give it a try later today.

        https://github.com/ksnip/ksnip

        1 Reply Last reply
        0
        • JonBJ JonB

          @dporobic
          I have not looked at the code you are using from singleton instance, but you might read the accepted solution to https://stackoverflow.com/questions/42549904/qsharedmemory-is-not-getting-deleted-on-application-crash.

          dporobicD Offline
          dporobicD Offline
          dporobic
          wrote on last edited by
          #4

          @JonB

          This seems to be working, here my solution:
          https://github.com/ksnip/ksnip/blob/master/src/bootstrapper/singleInstance/InstanceLock.h
          https://github.com/ksnip/ksnip/blob/master/src/bootstrapper/singleInstance/InstanceLock.cpp

          https://github.com/ksnip/ksnip

          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