Mercurial > libervia-desktop-kivy
changeset 265:805c4103dac5
core: resync widgets only when they are visible:
using AUTO_RESYNC from QuickApp was causing performance trouble (resynchronising all widgets was freezing the frontend for a little while).
By resynchronising only when the widget is visible, this should be greatly improved.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 11 Mar 2019 08:39:43 +0100 |
parents | 3e11b5d923e2 |
children | b3f97729e983 |
files | cagou/core/cagou_main.py cagou/plugins/plugin_wid_chat.py |
diffstat | 2 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/cagou/core/cagou_main.py Mon Mar 11 08:39:43 2019 +0100 +++ b/cagou/core/cagou_main.py Mon Mar 11 08:39:43 2019 +0100 @@ -380,6 +380,7 @@ class Cagou(QuickApp): MB_HANDLE = False + AUTO_RESYNC = False def __init__(self): if bridge_name == 'embedded': @@ -430,6 +431,15 @@ for w in w_list: yield w + @QuickApp.sync.setter + def sync(self, state): + QuickApp.sync.fset(self, state) + # widget are resynchronised in onVisible event, + # so we must call resync for widgets which are already visible + if state: + for w in self.visible_widgets: + w.resync() + def onBridgeConnected(self): super(Cagou, self).onBridgeConnected() self.registerSignal("otrState", iface="plugin")
--- a/cagou/plugins/plugin_wid_chat.py Mon Mar 11 08:39:43 2019 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Mon Mar 11 08:39:43 2019 +0100 @@ -678,6 +678,10 @@ self.encryption_btn.symbol = self.encryption_btn.getSymbol() self.encryption_btn.color = self.encryption_btn.getColor() + def onVisible(self): + if not self.sync: + self.resync() + def onDelete(self): # we always keep one widget, so it's available when swiping # TODO: delete all widgets when chat is closed