mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -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):
|
def __init__(self, browser, model):
|
||||||
QItemDelegate.__init__(self, browser)
|
QItemDelegate.__init__(self, browser)
|
||||||
|
self.browser = browser
|
||||||
self.model = model
|
self.model = model
|
||||||
|
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
|
self.browser.mw.progress.blockUpdates = True
|
||||||
try:
|
try:
|
||||||
c = self.model.getCard(index)
|
c = self.model.getCard(index)
|
||||||
except:
|
except:
|
||||||
# in the the middle of a reset; return nothing so this row is not
|
# in the the middle of a reset; return nothing so this row is not
|
||||||
# rendered until we have a chance to reset the model
|
# rendered until we have a chance to reset the model
|
||||||
return
|
return
|
||||||
|
finally:
|
||||||
|
self.browser.mw.progress.blockUpdates = True
|
||||||
col = None
|
col = None
|
||||||
if c.note().hasTag("Marked"):
|
if c.note().hasTag("Marked"):
|
||||||
col = COLOUR_MARKED
|
col = COLOUR_MARKED
|
||||||
|
|
|
@ -18,6 +18,7 @@ class ProgressManager(object):
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.app = QApplication.instance()
|
self.app = QApplication.instance()
|
||||||
self.inDB = False
|
self.inDB = False
|
||||||
|
self.blockUpdates = False
|
||||||
self._win = None
|
self._win = None
|
||||||
self._levels = 0
|
self._levels = 0
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ Your pysqlite2 is too old. Anki will appear frozen during long operations."""
|
||||||
# ensure timers don't fire
|
# ensure timers don't fire
|
||||||
self.inDB = True
|
self.inDB = True
|
||||||
# handle GUI events
|
# handle GUI events
|
||||||
|
if not self.blockUpdates:
|
||||||
self._maybeShow()
|
self._maybeShow()
|
||||||
self.app.processEvents(QEventLoop.ExcludeUserInputEvents)
|
self.app.processEvents(QEventLoop.ExcludeUserInputEvents)
|
||||||
self.inDB = False
|
self.inDB = False
|
||||||
|
|
Loading…
Reference in a new issue