branch: externals/bluetooth commit 8cac69d85fa63bf948a7cea2fa00d3cc4f2a245b Author: Raffael Stocker <r.stoc...@mnet-mail.de> Commit: Raffael Stocker <r.stoc...@mnet-mail.de>
checks list-id for nil to avoid errors at actions w/o list item --- bluetooth.el | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/bluetooth.el b/bluetooth.el index 9ea275d..53c7ca7 100644 --- a/bluetooth.el +++ b/bluetooth.el @@ -300,25 +300,30 @@ devices, as well as setting properties." ;;; Invoke a D-Bus method with or without parameters. (defun bluetooth--dbus-method (method api &rest args) "Invoke METHOD on D-Bus API with ARGS." - (apply #'bluetooth--call-method (tabulated-list-get-id) api - #'dbus-call-method-asynchronously method - #'bluetooth--update-list :timeout bluetooth--timeout args)) + (let ((dev-id (tabulated-list-get-id))) + (when dev-id + (apply #'bluetooth--call-method dev-id api + #'dbus-call-method-asynchronously method + #'bluetooth--update-list :timeout bluetooth--timeout args)))) ;;; Toggle a property. (defun bluetooth--dbus-toggle (property api) "Toggle boolean PROPERTY on D-Bus API." - (let* ((dev-id (tabulated-list-get-id)) - (value (bluetooth--call-method dev-id api - #'dbus-get-property property))) - (bluetooth--call-method dev-id api #'dbus-set-property property (not value)) - (bluetooth--update-list))) + (let ((dev-id (tabulated-list-get-id))) + (when dev-id + (let ((value (bluetooth--call-method dev-id api + #'dbus-get-property property))) + (bluetooth--call-method dev-id api #'dbus-set-property property + (not value)) + (bluetooth--update-list))))) ;;; Set a property. (defun bluetooth--dbus-set (property arg api) "Set PROPERTY to ARG on D-Bus API." - (bluetooth--call-method (tabulated-list-get-id) - api #'dbus-set-property property arg) - (bluetooth--update-list)) + (let ((dev-id (tabulated-list-get-id))) + (when dev-id + (bluetooth--call-method dev-id api #'dbus-set-property property arg) + (bluetooth--update-list)))) ;;; end of worker function definitions