diff --git a/comictaggerlib/coverimagewidget.py b/comictaggerlib/coverimagewidget.py index aef5459..c167ca5 100644 --- a/comictaggerlib/coverimagewidget.py +++ b/comictaggerlib/coverimagewidget.py @@ -60,7 +60,7 @@ class CoverImageWidget(QtWidgets.QWidget): URLMode = 1 DataMode = 3 - image_fetch_complete = QtCore.pyqtSignal(QtCore.QByteArray) + image_fetch_complete = QtCore.pyqtSignal(str, QtCore.QByteArray) def __init__( self, @@ -201,7 +201,7 @@ class CoverImageWidget(QtWidgets.QWidget): elif self.mode in [CoverImageWidget.AltCoverMode, CoverImageWidget.URLMode]: self.load_url() elif self.mode == CoverImageWidget.DataMode: - self.cover_remote_fetch_complete(self.imageData) + self.cover_remote_fetch_complete("", self.imageData) else: self.load_page() @@ -238,7 +238,9 @@ class CoverImageWidget(QtWidgets.QWidget): self.cover_fetcher.fetch(self.url_list[self.imageIndex]) # called when the image is done loading from internet - def cover_remote_fetch_complete(self, image_data: bytes) -> None: + def cover_remote_fetch_complete(self, url: str, image_data: bytes) -> None: + if url and url not in self.url_list: + return img = get_qimage_from_data(image_data) self.current_pixmap = QtGui.QPixmap.fromImage(img) self.set_display_pixmap() diff --git a/comictaggerlib/imagefetcher.py b/comictaggerlib/imagefetcher.py index 779340f..05b1afe 100644 --- a/comictaggerlib/imagefetcher.py +++ b/comictaggerlib/imagefetcher.py @@ -41,7 +41,7 @@ class ImageFetcherException(Exception): ... -def fetch_complete(image_data: bytes | QtCore.QByteArray) -> None: +def fetch_complete(url: str, image_data: bytes | QtCore.QByteArray) -> None: ... @@ -79,22 +79,22 @@ class ImageFetcher: # first look in the DB image_data = self.get_image_from_cache(url) # Async for retrieving covers seems to work well - if blocking: # if blocking or not qt_available: + if blocking or not qt_available: if not image_data: try: image_data = requests.get(url, headers={"user-agent": "comictagger/" + ctversion.version}).content + # save the image to the cache + self.add_image_to_cache(self.fetched_url, image_data) except Exception as e: logger.exception("Fetching url failed: %s") raise ImageFetcherException("Network Error!") from e - - # save the image to the cache - self.add_image_to_cache(self.fetched_url, image_data) + ImageFetcher.image_fetch_complete(url, image_data) return image_data if qt_available: # if we found it, just emit the signal asap if image_data: - ImageFetcher.image_fetch_complete(QtCore.QByteArray(image_data)) + ImageFetcher.image_fetch_complete(url, QtCore.QByteArray(image_data)) return b"" # didn't find it. look online @@ -110,9 +110,9 @@ class ImageFetcher: image_data = reply.readAll() # save the image to the cache - self.add_image_to_cache(self.fetched_url, image_data) + self.add_image_to_cache(reply.request().url().toString(), image_data) - ImageFetcher.image_fetch_complete(image_data) + ImageFetcher.image_fetch_complete(reply.request().url().toString(), image_data) def create_image_db(self) -> None: # this will wipe out any existing version diff --git a/comictaggerlib/issueselectionwindow.py b/comictaggerlib/issueselectionwindow.py index b6532a7..f1b9e9c 100644 --- a/comictaggerlib/issueselectionwindow.py +++ b/comictaggerlib/issueselectionwindow.py @@ -106,7 +106,7 @@ class IssueSelectionWindow(QtWidgets.QDialog): # now that the list has been sorted, find the initial record, and # select it - if self.initial_id is None: + if not self.initial_id: self.twList.selectRow(0) else: for r in range(0, self.twList.rowCount()): diff --git a/comictaggerlib/seriesselectionwindow.py b/comictaggerlib/seriesselectionwindow.py index 2da9f59..9a208bb 100644 --- a/comictaggerlib/seriesselectionwindow.py +++ b/comictaggerlib/seriesselectionwindow.py @@ -326,6 +326,8 @@ class SeriesSelectionWindow(QtWidgets.QDialog): self.issue_number = selector.issue_number self.issue_id = selector.issue_id self.accept() + else: + self.imageWidget.update_content() def select_by_id(self) -> None: for r in range(0, self.twList.rowCount()):