Qt single instance app how to Manage on crash
-
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 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.
-
[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.
-
What doesn't work ?
-
You could also use D-Bus in stead of shared memory.
-
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). -
[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.
-
exact.