changeset 437:b5e6d36fbf9c

chat: set AttachmentImageItem in python instead of kv: "source" is a StringProperty, and setting it in kv was in some case resulting in a "None" set, which was leading to a crash when Kivy cache was purged. It is now set in Python to avoid this problem.
author Goffi <goffi@goffi.org>
date Sat, 07 Mar 2020 00:05:49 +0100
parents 036ff0ed7474
children 58d3ea442f9c
files cagou/plugins/plugin_wid_chat.kv cagou/plugins/plugin_wid_chat.py
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.kv	Sun Mar 01 22:11:25 2020 +0100
+++ b/cagou/plugins/plugin_wid_chat.kv	Sat Mar 07 00:05:49 2020 +0100
@@ -57,7 +57,6 @@
     orientation: "vertical"
     SizedImage:
         id: image
-        source: root.data.get('preview') or root.data.get('path') or root.data.get('url')
         anim_delay: -1
 
 
--- a/cagou/plugins/plugin_wid_chat.py	Sun Mar 01 22:11:25 2020 +0100
+++ b/cagou/plugins/plugin_wid_chat.py	Sat Mar 07 00:05:49 2020 +0100
@@ -132,6 +132,11 @@
         gallery = ImagesGallery(sources=[full_size_source])
         G.host.showExtraUI(gallery)
 
+    def on_data(self, __, data):
+        source = data.get('preview') or data.get('path') or data.get('url')
+        if source:
+            self.source = source
+
 
 class AttachmentImagesCollectionItem(ButtonBehavior, GridLayout):
     attachments = properties.ListProperty([])