From b627fd4fc6a0bc212b646336ed0206a8f1e768d5 Mon Sep 17 00:00:00 2001 From: Michael James Gratton Date: Fri, 8 Dec 2017 00:00:48 +1100 Subject: [PATCH] Fix another avatar-related critical. * src/client/conversation-viewer/conversation-message.vala (ConversationMessage.load_avatar): We are very occasionally getting crashes calling Gtk.Image.get_pixel_size() due to the image is null - maybe a race? This obviates the problem by hard-coding the size instead of dynamically getting it. --- .../conversation-viewer/conversation-message.vala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client/conversation-viewer/conversation-message.vala b/src/client/conversation-viewer/conversation-message.vala index 8752f837..2c01e9ef 100644 --- a/src/client/conversation-viewer/conversation-message.vala +++ b/src/client/conversation-viewer/conversation-message.vala @@ -429,10 +429,18 @@ public class ConversationMessage : Gtk.Grid { */ public async void load_avatar(ConversationListBox.AvatarStore loader, Cancellable load_cancelled) { + const int PIXEL_SIZE = 32; Geary.RFC822.MailboxAddress? primary = message.get_primary_originator(); if (primary != null) { int window_scale = get_scale_factor(); - int pixel_size = this.avatar.get_pixel_size() * window_scale; + // We occasionally get crashes calling as below + // Gtk.Image.get_pixel_size() when the image is + // null. There's perhaps some race going on there. So we + // need to hard-code the size and keep it in sync with + // ui/conversation-message.ui. :( + // + //int pixel_size = this.avatar.get_pixel_size() * window_scale; + int pixel_size = PIXEL_SIZE * window_scale; try { Gdk.Pixbuf? avatar_buf = yield loader.load( primary, pixel_size, load_cancelled