--- a/Helpviewer/SpeedDial/SpeedDial.py Wed Feb 07 18:57:46 2018 +0100 +++ b/Helpviewer/SpeedDial/SpeedDial.py Wed Feb 07 20:14:09 2018 +0100 @@ -316,7 +316,8 @@ thumbnailer = PageThumbnailer(self) thumbnailer.setUrl(QUrl.fromEncoded(url.encode("utf-8"))) thumbnailer.setLoadTitle(loadTitle) - thumbnailer.thumbnailCreated.connect(self.__thumbnailCreated) + thumbnailer.thumbnailCreated.connect( + lambda imag: self.__thumbnailCreated(imag, thumbnailer)) self.__thumbnailers.append(thumbnailer) thumbnailer.start() @@ -388,48 +389,47 @@ """ return self.__speedDialSize - def __thumbnailCreated(self, image): + def __thumbnailCreated(self, image, thumbnailer): """ Private slot to handle the creation of a thumbnail image. - @param image thumbnail image (QPixmap) + @param image thumbnail image + @type QPixmap + @param thumbnailer reference to the page thumbnailer + @type PageThumbnailer """ - from .PageThumbnailer import PageThumbnailer - thumbnailer = self.sender() - if not isinstance(thumbnailer, PageThumbnailer) or \ - thumbnailer not in self.__thumbnailers: - return - - loadTitle = thumbnailer.loadTitle() - title = thumbnailer.title() - url = thumbnailer.url().toString() - fileName = self.__imageFileName(url) - - if image.isNull(): - fileName = "qrc:icons/brokenPage.png" - title = self.tr("Unable to load") - loadTitle = True - page = self.pageForUrl(thumbnailer.url()) - page.broken = True - else: - if not image.save(fileName): - qWarning( - "SpeedDial.__thumbnailCreated: Cannot save thumbnail" - " to {0}".format(fileName)) + if thumbnailer in self.__thumbnailers: + loadTitle = thumbnailer.loadTitle() + title = thumbnailer.title() + url = thumbnailer.url().toString() + fileName = self.__imageFileName(url) - fileName = QUrl.fromLocalFile(fileName).toString() - - self.__regenerateScript = True - - for frame in self.__cleanFrames(): - frame.evaluateJavaScript("setImageToUrl('{0}', '{1}');".format( - url, fileName)) - if loadTitle: - frame.evaluateJavaScript("setTitleToUrl('{0}', '{1}');".format( - url, Utilities.html_uencode(title))) - - thumbnailer.deleteLater() - self.__thumbnailers.remove(thumbnailer) + if image.isNull(): + fileName = "qrc:icons/brokenPage.png" + title = self.tr("Unable to load") + loadTitle = True + page = self.pageForUrl(thumbnailer.url()) + page.broken = True + else: + if not image.save(fileName): + qWarning( + "SpeedDial.__thumbnailCreated: Cannot save thumbnail" + " to {0}".format(fileName)) + + fileName = QUrl.fromLocalFile(fileName).toString() + + self.__regenerateScript = True + + for frame in self.__cleanFrames(): + frame.evaluateJavaScript("setImageToUrl('{0}', '{1}');".format( + url, fileName)) + if loadTitle: + frame.evaluateJavaScript( + "setTitleToUrl('{0}', '{1}');".format( + url, Utilities.html_uencode(title))) + + thumbnailer.deleteLater() + self.__thumbnailers.remove(thumbnailer) def __cleanFrames(self): """