[Gambas-user] Single instance application, anyone else done it?
g4mba5 at gmail.com
Wed Jul 7 20:05:34 CEST 2021
Le 07/07/2021 à 15:18, Bruce Steers a écrit :
> Excellent thank you Tony :)
> I was so close lol, things are working now though thanks to your help.
> Much appreciated :)
Actually doing that:
If DBus.Session.Applications.Exist(TEXTEDITOR_DBUS_NAME) Then
to know if you are already on the bus is wrong, because it's not atomic.
You must instead set the DBus.Unique property to TRUE before
registering, so that a unique name is used.
That way, if you register on the DBus bus again, you will get an error,
and it will be atomic.
So you should do instead:
DBus.Unique = TRUE
hDbusObj = New DbusObj
' Registering the first object automatically registers the application.
Try DBus.Session.Register(hDbusObj, TEXTEDITOR_PATH,
If Error Then
' We suppose we are already registered.
If Files.Count > 0 Then
For Each $file In Files
Try DBus[DBus.Name][TEXTEDITOR_PATH, TEXTEDITOR_DBUS_INTERFACE].Show()
Tell me if it actually works!
More information about the User