diff cagou/plugins/plugin_wid_chat.py @ 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 53bb3886b408
children ff548846df91
line wrap: on
line diff
--- 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([])