Fix: (ement-room--m.image-callback) Workaround rare bug

I'm not sure what can cause this.  While I've heard a couple of
reports from users, this is the first time it's happened to me.  It
might be caused by an earlier error interrupting sync processing,
leaving a room data or buffer in an inconsistent state.  Anyway, this
should prevent it from being a problem, while still leaving a way to
potentially learn the cause so it can be truly solved.
This commit is contained in:
Adam Porter 2022-06-27 01:01:30 -05:00
parent 033e155061
commit 2253e97753

View file

@ -3761,9 +3761,17 @@ Then invalidate EVENT's node to show the image."
(setf (map-elt (ement-event-local event) 'image) data)
(when (buffer-live-p buffer)
(with-current-buffer buffer
(ewoc-invalidate ement-ewoc (ement-room--ewoc-last-matching ement-ewoc
(lambda (node-data)
(eq node-data event))))))))
(if-let (node (ement-room--ewoc-last-matching ement-ewoc
(lambda (node-data)
(eq node-data event))))
(ewoc-invalidate ement-ewoc node)
;; This shouldn't happen, but very rarely, it can. I haven't figured out why
;; yet, so checking whether a node is found rather than blindly calling
;; `ewoc-invalidate' prevents an error from aborting event processing.
(display-warning 'ement-room--m.image-callback
(format "Event %S not found in room %S (a very rare, as-yet unexplained bug, which can be safely ignored; you may disconnect and reconnect if you wish, but it isn't strictly necessary)"
(ement-event-id event)
(ement-room-display-name room))))))))
(defun ement-room--format-m.file (event)
"Return \"m.file\" EVENT formatted as a string."