mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
block gui updates while painting browser rows
If we processEvents() in the middle of a QItemDelegate, the recursion can cause a crash on some OSes
This commit is contained in:
parent
f54c2f7835
commit
0055d31d04
2 changed files with 8 additions and 2 deletions
|
@ -296,15 +296,19 @@ class StatusDelegate(QItemDelegate):
|
|||
|
||||
def __init__(self, browser, model):
|
||||
QItemDelegate.__init__(self, browser)
|
||||
self.browser = browser
|
||||
self.model = model
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
self.browser.mw.progress.blockUpdates = True
|
||||
try:
|
||||
c = self.model.getCard(index)
|
||||
except:
|
||||
# in the the middle of a reset; return nothing so this row is not
|
||||
# rendered until we have a chance to reset the model
|
||||
return
|
||||
finally:
|
||||
self.browser.mw.progress.blockUpdates = True
|
||||
col = None
|
||||
if c.note().hasTag("Marked"):
|
||||
col = COLOUR_MARKED
|
||||
|
|
|
@ -18,6 +18,7 @@ class ProgressManager(object):
|
|||
self.mw = mw
|
||||
self.app = QApplication.instance()
|
||||
self.inDB = False
|
||||
self.blockUpdates = False
|
||||
self._win = None
|
||||
self._levels = 0
|
||||
|
||||
|
@ -49,8 +50,9 @@ Your pysqlite2 is too old. Anki will appear frozen during long operations."""
|
|||
# ensure timers don't fire
|
||||
self.inDB = True
|
||||
# handle GUI events
|
||||
self._maybeShow()
|
||||
self.app.processEvents(QEventLoop.ExcludeUserInputEvents)
|
||||
if not self.blockUpdates:
|
||||
self._maybeShow()
|
||||
self.app.processEvents(QEventLoop.ExcludeUserInputEvents)
|
||||
self.inDB = False
|
||||
|
||||
# DB-safe timers
|
||||
|
|
Loading…
Reference in a new issue