[Gambas-user] Error during registration on the D-Bus
T Lee Davidson
t.lee.davidson at gmail.com
Sun Mar 11 09:29:25 CET 2018
On 03/11/2018 04:02 AM, Benoît Minisini wrote:
> Le 10/03/2018 à 18:32, Hans Lehmann a écrit :
>> DBus.Unique = True
>>
>> If DBus.IsRegistered(Service) Then
>
> Of course, Service is an object in your program. If you run the program twice, you have a different Service object which is
> never registered at program start.
>
> Registering an object is different from subscribing an application to the DBus, which is done automatically by the component.
>
> You don't have a method that will tell you that your application is already registered. If you had one, it won't work anyway
> because of the race condition it will imply.
>
> So you have to deal with DBus.Unique only, and wait for an error telling you that your application is already registered.
>
> Regards,
>
You snuck that one in while I was composing the one I just sent.
And I wonder now why I made it so complicated. Duh.
[code]
Try DBus.Session.Register(Service, "/Service")
If Error Then
Message.Error("An instance of " & Application.Name & " already exists.")
FMain.Close()
Else
DBus.Session.Register(Service, "/Service")
Endif
[/code]
--
Lee
More information about the User
mailing list