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 Updated to NodeBB v4.3 + New Features

Qt single instance app how to Manage on crash

Scheduled Pinned Locked Moved General and Desktop
13 Posts 6 Posters 3.5k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 18 Feb 2015, 22:57 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 19 Feb 2015, 08:26 last edited by
      #5

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sierdzio
        Moderators
        wrote on 19 Feb 2015, 08:29 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 19 Feb 2015, 08:31 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 19 Feb 2015, 08:33 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
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 23 Feb 2015, 20:59 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 23 Feb 2015, 21:06 last edited by
                #10

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

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jerome_isAviable
                  wrote on 24 Feb 2015, 02:58 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
                  • S Offline
                    S Offline
                    sierdzio
                    Moderators
                    wrote on 24 Feb 2015, 06:48 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
                    • J Offline
                      J Offline
                      jerome_isAviable
                      wrote on 24 Feb 2015, 07:37 last edited by
                      #13

                      exact.

                      1 Reply Last reply
                      0

                      13/13

                      24 Feb 2015, 07:37

                      • Login

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