emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ement 6bd1091757 1/6: Fix: (-defevent "m.room.avatar")


From: ELPA Syncer
Subject: [elpa] externals/ement 6bd1091757 1/6: Fix: (-defevent "m.room.avatar") Warn for unreadable images
Date: Sun, 14 May 2023 00:58:06 -0400 (EDT)

branch: externals/ement
commit 6bd1091757bce5feedb337d01b88ab0aa3bc6124
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Fix: (-defevent "m.room.avatar") Warn for unreadable images
    
    If Emacs can't load a room's avatar image, `create-image' returns nil.
    This can happen if, e.g. the image is corrupt or an unreadable
    format (such as an ICO file).
    
    See <https://github.com/alphapapa/ement.el/issues/147>.
    
    Fixes #147.  Thanks to @jgarte for reporting.
---
 README.org |  1 +
 ement.el   | 26 ++++++++++++++++----------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/README.org b/README.org
index 6032ef116e..c20f85d7ae 100644
--- a/README.org
+++ b/README.org
@@ -311,6 +311,7 @@ Note that, while ~matrix-client~ remains usable, and 
probably will for some time
 *Fixes*
 
 + Recognition of certain MXID or displayname forms in outgoing messages when 
linkifying (aka "pilling") them.
++ Unreadable room avatar images no longer cause errors.  (Fixes 
[[https://github.com/alphapapa/ement.el/issues/147][#147]].  Thanks to 
[[https://github.com/jgarte][@jgarte]] for reporting.)
 
 ** 0.8.3
 
diff --git a/ement.el b/ement.el
index 0c5eded2c3..32ade69817 100644
--- a/ement.el
+++ b/ement.el
@@ -874,16 +874,22 @@ and `session' to the session.  Adds function to
                                                 :ascent 'center
                                                 :max-width 
ement-room-avatar-max-width
                                                 :max-height 
ement-room-avatar-max-height)))
-                       (when (fboundp 'imagemagick-types)
-                         ;; Only do this when ImageMagick is supported.
-                         ;; FIXME: When requiring Emacs 27+, remove this (I 
guess?).
-                         (setf (image-property image :type) 'imagemagick))
-                       ;; We set the room-avatar slot to a propertized string 
that
-                       ;; displays as the image.  This seems the most 
convenient thing to
-                       ;; do.  We also unset the cached room-list-avatar so it 
can be
-                       ;; remade.
-                       (setf (ement-room-avatar room) (propertize " " 'display 
image)
-                             (alist-get 'room-list-avatar (ement-room-local 
room)) nil))))))
+                       (if (not image)
+                           (progn
+                             (display-warning 'ement (format "Room avatar 
seems unreadable:  ROOM-ID:%S  AVATAR-URL:%S"
+                                                             (ement-room-id 
room) (ement--mxc-to-url url session)))
+                             (setf (ement-room-avatar room) nil
+                                   (alist-get 'room-list-avatar 
(ement-room-local room)) nil))
+                         (when (fboundp 'imagemagick-types)
+                           ;; Only do this when ImageMagick is supported.
+                           ;; FIXME: When requiring Emacs 27+, remove this (I 
guess?).
+                           (setf (image-property image :type) 'imagemagick))
+                         ;; We set the room-avatar slot to a propertized 
string that
+                         ;; displays as the image.  This seems the most 
convenient thing to
+                         ;; do.  We also unset the cached room-list-avatar so 
it can be
+                         ;; remade.
+                         (setf (ement-room-avatar room) (propertize " " 
'display image)
+                               (alist-get 'room-list-avatar (ement-room-local 
room)) nil)))))))
       ;; Unset avatar.
       (setf (ement-room-avatar room) nil
             (alist-get 'room-list-avatar (ement-room-local room)) nil))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]