stefano-m / lua-dbus_proxy

Simple API around GLib's GIO:GDBusProxy built on top of lgi
https://stefano-m.github.io/lua-dbus_proxy/
Apache License 2.0
17 stars 7 forks source link

disconnect from signal #1

Closed deb75 closed 6 years ago

deb75 commented 6 years ago

Hello,

I use the function :

proxy:connect_signal(callback, "PropertiesChanged", nil)

But sometimes, I would like to remove the function attached to the signal. But I did not find a function suitable for this. Ho can I do that ?

If I try to attach a void function, will it remove the callback one ?

proxy:connect_signal(function () end, "PropertiesChanged", nil)
stefano-m commented 6 years ago

Hello,

connect_signal uses GDBus' g-signal under the hood... well, actually it's lgi's magic plus g-signal.

Attaching a no-op callback to the signal as you describe should work (I never had a use case for this, so I can't really tell). I'd be interested to know from you whether that's actually the case.

stefano-m commented 6 years ago

Closing for lack of feedback.

deb75 commented 6 years ago

Hi,

Sorry for the delay :-) ... a small baby girl is just what you cannot delay :-)

I tested attaching a no-op callback, it does not work the way I would like.

Calling connect_signal several times attaches each function to the signal. So you may have several functions attached to the same signal.

Attaching again one different function with the same name does not replace the previous attached one (with the same name), it just adds it to the signal.

I would have expected the newly attached function to replace the one with the same name. I could not find in GDBus'g-signal documentation any method to disconnect or deattach a callback function.

Regards

stefano-m commented 6 years ago

No problem! One's gotta do what they gotta do ;)

TBH, I am a bit clueless. You could try to delete the whole proxy object (i.e. assign it to nil) and check whether the signal goes away. I think that I've run out of options though.

If you manage to find a possible solution, feel free to reopen this issue (or a new one).

Thanks