From bd8063284c7d3f5f6a2646e91b4f14e87e2765a8 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 7 Apr 2020 13:00:41 +0200 Subject: [PATCH] Fix runtime criticals when showing resource identites on conversation row hover --- .../conversation_selector_row.vala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala index 6dc953df..467bed70 100644 --- a/main/src/ui/conversation_selector/conversation_selector_row.vala +++ b/main/src/ui/conversation_selector/conversation_selector_row.vala @@ -254,8 +254,7 @@ public class ConversationSelectorRow : ListBoxRow { Xep.ServiceDiscovery.Identity? identity = stream_interactor.get_module(EntityInfo.IDENTITY).get_identity(conversation.account, full_jid); Image image = new Image() { hexpand=false, valign=Align.START, visible=true }; - grid.attach(image, 0, i + 1, 1, 1); - if (identity != null && identity.type_ == Xep.ServiceDiscovery.Identity.TYPE_PHONE || identity.type_ == Xep.ServiceDiscovery.Identity.TYPE_TABLET) { + if (identity != null && (identity.type_ == Xep.ServiceDiscovery.Identity.TYPE_PHONE || identity.type_ == Xep.ServiceDiscovery.Identity.TYPE_TABLET)) { image.set_from_icon_name("dino-device-phone-symbolic", IconSize.SMALL_TOOLBAR); } else { image.set_from_icon_name("dino-device-desktop-symbolic", IconSize.SMALL_TOOLBAR); @@ -279,12 +278,14 @@ public class ConversationSelectorRow : ListBoxRow { } var sb = new StringBuilder(); - if (identity.name != null) { + if (identity != null && identity.name != null) { sb.append(identity.name); - } else if (dino_resource_regex.match(full_jid.resourcepart)) { + } else if (full_jid.resourcepart != null && dino_resource_regex.match(full_jid.resourcepart)) { sb.append("Dino"); - } else { + } else if (full_jid.resourcepart != null) { sb.append(full_jid.resourcepart); + } else { + continue; } if (status != null) { sb.append(" ("); @@ -293,6 +294,8 @@ public class ConversationSelectorRow : ListBoxRow { } Label resource = new Label(sb.str) { use_markup=true, hexpand=true, xalign=0, visible=true }; + + grid.attach(image, 0, i + 1, 1, 1); grid.attach(resource, 1, i + 1, 1, 1); } return grid;