[Gambas-user] DBus oddity with startup application.

Benoît Minisini g4mba5 at gmail.com
Mon Aug 9 22:49:22 CEST 2021


Le 09/08/2021 à 22:27, Bruce Steers a écrit :
> 
> 
> On Mon, 9 Aug 2021, 19:33 Benoît Minisini, <g4mba5 at gmail.com 
> <mailto:g4mba5 at gmail.com>> wrote:
> 
>     Le 09/08/2021 à 20:24, Bruce Steers a écrit :
>      >
>      > I've fixed the problem with this in my FMain.class ...
>      >
>      > *Static Public Sub _init()
>      > *
>      > *If Not Exist("/tmp/dish_opened") Then
>      >      Wait 2
>      >      File.Save("/tmp/dish_opened", "true")
>      >    Endif
>      >
>      > End*
>      > that gives a couple of seconds and then the
>      > org.freedesktop.login1.Manager.PowerOff() function works
>      > if app is closed and relaunched it finds the file in /tmp/ and
>     does not
>      > wait and dbus is still okay.
>      >
>      >
>      > Seems any call to Dbus like DBus.System.Applications.Exist() in
>     _init()
>      > initialises dbus too early, it finds the login1
>     DBus.System.Applications
>      > but the Interfaces do not work.
> 
>     Then the problem is in the application that handles
>     'org.freedesktop.login1.Manager'.
> 
> 
> Seems quite odd that the login1 interface is not found but the login1 
> Application is unless I restart the program.

This is why I say it's a problem in the login1 application.

It registers on the DBus bus, but misteriously does not return the 
expected introspection data when you first call 
DBus["system://org.freedesktop.login1"]["/org/freedesktop/login1", 
"org.freedesktop.login1.Manager"].

I guess it does return the expected introspection later. The 'gb.dbus' 
component does not support DBus objects whose interface changes during 
their lifetime.

I could add a Refresh() method to the DBusApplication class, so that you 
can call DBus["system://org.freedesktop.login1"].Refresh() to clear all 
the internal caches.

But anyway you will have to wait an arbitrary amount of time, because 
apparently the "org.freedesktop.login1.Manager" interface does not 
appear immediately after the "login1" application register to the bus.

Look at the 'gb.dbus' source code to understand how all that works.

Regards,

-- 
Benoît Minisini


More information about the User mailing list