Subject: Re: bug#43146: 27.1; D-Bus property handling incomplete

From: Michael Albinus <[email-masked]>
Date: Wed, 02 Sep 2020 19:58:36 +0200

Hugh Daschbach <[email-masked]> writes:

Hi Hugh,

> When the same D-Bus property is registered on an interface with two
> separate paths, only the last property is preserved.  Methods and
> signals registered on the same interface on different paths are
> preserved.

I could reproduce the bug locally. The following patch solves it for me,
could you pls check?

Best regards, Michael.

*** /tmp/ediffkDjiXo	2020-09-02 19:51:41.334910903 +0200
--- /home/albinus/src/emacs/lisp/net/dbus.el	2020-09-02 19:40:00.173649689 +0200
***************
*** 1484,1498 ****

    ;; Create a hash table entry.  We use nil for the unique name,
    ;; because the property might be accessed from anybody.
!   (let ((key (list :property bus interface property))
! 	(val
! 	 (list
  	  (list
  	   nil service path
  	   (cons
  	    (if emits-signal (list access :emits-signal) (list access))
! 	    value)))))
!     (puthash key val dbus-registered-objects-table)

      ;; Return the object.
      (list key (list service path))))
--- 1484,1502 ----

    ;; Create a hash table entry.  We use nil for the unique name,
    ;; because the property might be accessed from anybody.
!   (let* ((key (list :property bus interface property))
!          ;; Remove possible existing entry, because it must be overwritten.
!          (val (seq-remove
!                (lambda (item)
!                  (equal (butlast item) (list nil service path)))
!                (gethash key dbus-registered-objects-table)))
! 	 (entry
  	  (list
  	   nil service path
  	   (cons
  	    (if emits-signal (list access :emits-signal) (list access))
! 	    value))))
!     (puthash key (cons entry val) dbus-registered-objects-table)

      ;; Return the object.
      (list key (list service path))))
***************
*** 1509,1517 ****
      (cond
       ;; "Get" returns a variant.
       ((string-equal method "Get")
!       (let ((entry (gethash (list :property bus interface property)
! 			    dbus-registered-objects-table)))
! 	(when (string-equal path (nth 2 (car entry)))
  	  `((:variant ,(cdar (last (car entry))))))))

       ;; "Set" expects a variant.
--- 1513,1527 ----
      (cond
       ;; "Get" returns a variant.
       ((string-equal method "Get")
!       (let ((entry
!              ;; Remove entries not belonging to this case.
!              (seq-remove
!               (lambda (item)
!                 (not (string-equal path (nth 2 item))))
!               (gethash (list :property bus interface property)
! 		       dbus-registered-objects-table))))
!
!         (when (string-equal path (nth 2 (car entry)))
  	  `((:variant ,(cdar (last (car entry))))))))

       ;; "Set" expects a variant.