diff cagou/core/cagou_main.py @ 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
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")