comparison 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
comparison
equal deleted inserted replaced
264:3e11b5d923e2 265:805c4103dac5
378 return False 378 return False
379 379
380 380
381 class Cagou(QuickApp): 381 class Cagou(QuickApp):
382 MB_HANDLE = False 382 MB_HANDLE = False
383 AUTO_RESYNC = False
383 384
384 def __init__(self): 385 def __init__(self):
385 if bridge_name == 'embedded': 386 if bridge_name == 'embedded':
386 from sat.core import sat_main 387 from sat.core import sat_main
387 self.sat = sat_main.SAT() 388 self.sat = sat_main.SAT()
428 def visible_widgets(self): 429 def visible_widgets(self):
429 for w_list in self._visible_widgets.itervalues(): 430 for w_list in self._visible_widgets.itervalues():
430 for w in w_list: 431 for w in w_list:
431 yield w 432 yield w
432 433
434 @QuickApp.sync.setter
435 def sync(self, state):
436 QuickApp.sync.fset(self, state)
437 # widget are resynchronised in onVisible event,
438 # so we must call resync for widgets which are already visible
439 if state:
440 for w in self.visible_widgets:
441 w.resync()
442
433 def onBridgeConnected(self): 443 def onBridgeConnected(self):
434 super(Cagou, self).onBridgeConnected() 444 super(Cagou, self).onBridgeConnected()
435 self.registerSignal("otrState", iface="plugin") 445 self.registerSignal("otrState", iface="plugin")
436 self.bridge.getReady(self.onBackendReady) 446 self.bridge.getReady(self.onBackendReady)
437 447