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. Qt single instance app how to Manage on crash
Forum Update on Monday, May 27th 2025

Qt single instance app how to Manage on crash

Scheduled Pinned Locked Moved General and Desktop
13 Posts 6 Posters 3.4k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Hi,

    Beware, you are doing your initialization twice. You're application should not start any initialization before checking it's not already running. Also that's a Windows specific implementation and the OP is running Ubuntu. sierdzio's suggestion is good. It works very well.

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

      My Initialisation is just to config the GUI ... (stylesheet ...)

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #6

        [quote author="Francknos" date="1424334416"]My Initialisation is just to config the GUI ... (stylesheet ...)[/quote]

        Yes, but it does start the application. So, for a tiny bit of time, you do have 2 instances of your application launched.

        (Z(:^

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Francknos
          wrote on last edited by
          #7

          Yes I have 2 instances of my aplpication during 2000 ms.
          But it's not a problem for me.

          I can check this in main so ...

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Francknos
            wrote on last edited by
            #8

            [quote author="SGaist" date="1424300270"]Hi,

            Beware, you are doing your initialization twice. You're application should not start any initialization before checking it's not already running. Also that's a Windows specific implementation and the OP is running Ubuntu. sierdzio's suggestion is good. It works very well.[/quote]

            I have tried this but it doesn't work with me.

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

              What doesn't work ?

              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
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #10

                You could also use D-Bus in stead of shared memory.

                1 Reply Last reply
                0
                • jerome_isAviableJ Offline
                  jerome_isAviableJ Offline
                  jerome_isAviable
                  wrote on last edited by
                  #11

                  you also can try to create and use a specific singleton class.
                  look at C++ codes/exemples for learn how to use well singleton class.
                  i do it for check login and users access/privileges.
                  after that, you can call your singleton by handle the "get_instance" method (for exemple).

                  1 Reply Last reply
                  0
                  • sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #12

                    [quote author="jerome_isAviable?" date="1424746717"]you also can try to create and use a specific singleton class.[/quote]

                    That won't work for this use case. Singleton has a single instance of a class per application - but there can be many applications launched. The OP wants to run only one instance of the application.

                    (Z(:^

                    1 Reply Last reply
                    0
                    • jerome_isAviableJ Offline
                      jerome_isAviableJ Offline
                      jerome_isAviable
                      wrote on last edited by
                      #13

                      exact.

                      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