gui: stop scrape-all dialog from reappearing after cancel
Cancelling the store scrape now closes the dialog and drops its reference immediately, so queued progress signals can't re-show it (QProgressDialog re-shows on setValue while a value is pending). _scraping stays true until the worker finishes to prevent a second concurrent scrape.
This commit is contained in:
+14
-1
@@ -2320,7 +2320,7 @@ class StorePage(QWidget):
|
|||||||
thread.started.connect(worker.run)
|
thread.started.connect(worker.run)
|
||||||
worker.progress.connect(self._on_scrape_progress)
|
worker.progress.connect(self._on_scrape_progress)
|
||||||
worker.finished.connect(thread.quit)
|
worker.finished.connect(thread.quit)
|
||||||
dlg.canceled.connect(worker.cancel)
|
dlg.canceled.connect(self._on_scrape_cancelled)
|
||||||
worker.finished.connect(self._on_scrape_done)
|
worker.finished.connect(self._on_scrape_done)
|
||||||
self._scrape_thread = thread
|
self._scrape_thread = thread
|
||||||
self._scrape_worker = worker
|
self._scrape_worker = worker
|
||||||
@@ -2328,6 +2328,19 @@ class StorePage(QWidget):
|
|||||||
self._workers.append(worker)
|
self._workers.append(worker)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
def _on_scrape_cancelled(self):
|
||||||
|
worker = self._scrape_worker
|
||||||
|
if worker is not None:
|
||||||
|
worker.cancel()
|
||||||
|
dlg = self._scrape_dialog
|
||||||
|
if dlg is not None:
|
||||||
|
dlg.close()
|
||||||
|
# Drop the dialog reference so queued progress signals can't re-show it
|
||||||
|
# (QProgressDialog re-appears on setValue while a value is pending).
|
||||||
|
# Keep _scraping True until the worker actually finishes (_on_scrape_done)
|
||||||
|
# so a re-click doesn't spawn a second scrape while this one winds down.
|
||||||
|
self._scrape_dialog = None
|
||||||
|
|
||||||
def _on_scrape_progress(self, done, total):
|
def _on_scrape_progress(self, done, total):
|
||||||
dlg = self._scrape_dialog
|
dlg = self._scrape_dialog
|
||||||
if dlg is not None:
|
if dlg is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user