From a82744a3e5d9ad8f3fda033b954c081ce6481f43 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 26 Jan 2021 09:02:08 +1000 Subject: [PATCH] load sidebar in background Allows the UI to repaint during processing, but will still block DB operations until the call completes. --- qt/aqt/sidebar.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qt/aqt/sidebar.py b/qt/aqt/sidebar.py index 919d0a5f3..0c68570e7 100644 --- a/qt/aqt/sidebar.py +++ b/qt/aqt/sidebar.py @@ -219,10 +219,13 @@ class SidebarTreeView(QTreeView): if not self.isVisible(): return - root = self._root_tree() - model = SidebarModel(root) - self.setModel(model) - model.expandWhereNeccessary(self) + def on_done(fut: Future): + root = fut.result() + model = SidebarModel(root) + self.setModel(model) + model.expandWhereNeccessary(self) + + self.mw.taskman.run_in_background(self._root_tree, on_done) def onClickCurrent(self) -> None: idx = self.currentIndex()