mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[view.qt] fix: QT crash in case the file downloader thread is still alive
This commit is contained in:
@@ -605,6 +605,9 @@ class PackagesTable(QTableWidget):
|
|||||||
self.file_downloader.signal_downloaded.connect(self._update_pkg_icon)
|
self.file_downloader.signal_downloaded.connect(self._update_pkg_icon)
|
||||||
self.file_downloader.start()
|
self.file_downloader.start()
|
||||||
|
|
||||||
def stop_file_downloader(self) -> None:
|
def stop_file_downloader(self, wait: bool = False) -> None:
|
||||||
if self.file_downloader:
|
if self.file_downloader:
|
||||||
self.file_downloader.stop()
|
self.file_downloader.stop()
|
||||||
|
|
||||||
|
if wait:
|
||||||
|
self.file_downloader.wait()
|
||||||
|
|||||||
@@ -1127,6 +1127,9 @@ class URLFileDownloader(QThread):
|
|||||||
self._stop = False
|
self._stop = False
|
||||||
|
|
||||||
def _get(self, url_: str, id_: Optional[object]):
|
def _get(self, url_: str, id_: Optional[object]):
|
||||||
|
if self._stop:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = requests.get(url=url_, timeout=self._request_timeout)
|
res = requests.get(url=url_, timeout=self._request_timeout)
|
||||||
content = res.content if res.status_code == 200 else None
|
content = res.content if res.status_code == 200 else None
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from pathlib import Path
|
|||||||
from typing import List, Type, Set, Tuple, Optional, Dict, Any
|
from typing import List, Type, Set, Tuple, Optional, Dict, Any
|
||||||
|
|
||||||
from PyQt5.QtCore import QEvent, Qt, pyqtSignal, QRect
|
from PyQt5.QtCore import QEvent, Qt, pyqtSignal, QRect
|
||||||
from PyQt5.QtGui import QIcon, QWindowStateChangeEvent, QCursor
|
from PyQt5.QtGui import QIcon, QWindowStateChangeEvent, QCursor, QCloseEvent
|
||||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QCheckBox, QHeaderView, QToolBar, \
|
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QCheckBox, QHeaderView, QToolBar, \
|
||||||
QLabel, QPlainTextEdit, QProgressBar, QPushButton, QComboBox, QApplication, QListView, QSizePolicy, \
|
QLabel, QPlainTextEdit, QProgressBar, QPushButton, QComboBox, QApplication, QListView, QSizePolicy, \
|
||||||
QMenu, QHBoxLayout
|
QMenu, QHBoxLayout
|
||||||
@@ -1767,3 +1767,7 @@ class ManageWindow(QWidget):
|
|||||||
self.verify_warnings()
|
self.verify_warnings()
|
||||||
self.types_changed = True
|
self.types_changed = True
|
||||||
self.begin_refresh_packages()
|
self.begin_refresh_packages()
|
||||||
|
|
||||||
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
|
# needs to be stopped to avoid a Qt exception/crash
|
||||||
|
self.table_apps.stop_file_downloader(wait=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user