prevent recursive progress dialog invocations

This commit is contained in:
Damien Elmes 2010-01-20 19:01:39 +09:00
parent 1cfef7a295
commit bd532500ef

View file

@ -2566,24 +2566,30 @@ it to your friends.
if self.mainThread != QThread.currentThread(): if self.mainThread != QThread.currentThread():
return return
self.setBusy() self.setBusy()
parent = self.progressParent or self.app.activeWindow() or self if not self.progressWins:
if self.progressWins: parent = self.progressParent or self.app.activeWindow() or self
parent = self.progressWins[-1].diag p = ui.utils.ProgressWin(parent, max, min, title)
p = ui.utils.ProgressWin(parent, max, min, title) else:
p = None
self.progressWins.append(p) self.progressWins.append(p)
def updateProgress(self, label=None, value=None, process=True): def updateProgress(self, label=None, value=None, process=True):
if self.mainThread != QThread.currentThread(): if self.mainThread != QThread.currentThread():
return return
if self.progressWins: if len(self.progressWins) == 1:
self.progressWins[-1].update(label, value, process) self.progressWins[0].update(label, value, process)
else:
# just redraw
if process:
self.app.processEvents()
def finishProgress(self): def finishProgress(self):
if self.mainThread != QThread.currentThread(): if self.mainThread != QThread.currentThread():
return return
if self.progressWins: if self.progressWins:
p = self.progressWins.pop() p = self.progressWins.pop()
p.finish() if p:
p.finish()
if not self.progressWins: if not self.progressWins:
self.unsetBusy() self.unsetBusy()