eric6/WebBrowser/Tools/WebIconLoader.py

changeset 7766
0af772bc14c4
parent 7764
1804cdcedac7
child 7781
607a6098cb44
--- a/eric6/WebBrowser/Tools/WebIconLoader.py	Wed Oct 07 17:58:51 2020 +0200
+++ b/eric6/WebBrowser/Tools/WebIconLoader.py	Wed Oct 07 19:14:36 2020 +0200
@@ -12,6 +12,12 @@
 from PyQt5.QtGui import QIcon, QPixmap, QImage
 from PyQt5.QtNetwork import QNetworkRequest, QSslConfiguration
 
+try:
+    from PyQt5.QtNetwork import QSslConfiguration     # __IGNORE_WARNING__
+    SSL_AVAILABLE = True
+except ImportError:
+    SSL_AVAILABLE = False
+
 import WebBrowser.WebBrowserWindow
 
 
@@ -21,9 +27,12 @@
     
     @signal iconLoaded(icon) emitted when the icon has been loaded
     @signal sslConfiguration(config) emitted to pass the SSL data
+    @signal clearSslConfiguration() emitted to clear stored SSL data
     """
     iconLoaded = pyqtSignal(QIcon)
-    sslConfiguration = pyqtSignal(QSslConfiguration)
+    if SSL_AVAILABLE:
+        sslConfiguration = pyqtSignal(QSslConfiguration)
+        clearSslConfiguration = pyqtSignal()
     
     def __init__(self, url, parent=None):
         """
@@ -52,10 +61,12 @@
         icon = QIcon(QPixmap.fromImage(QImage.fromData(data)))
         self.iconLoaded.emit(icon)
         
-        # TODO: extract SSL data as a by-product
-        if self.__reply.url().scheme().lower() == "https":
-            sslConfiguration = self.__reply.sslConfiguration()
-            self.sslConfiguration.emit(sslConfiguration)
+        if SSL_AVAILABLE:
+            if self.__reply.url().scheme().lower() == "https":
+                sslConfiguration = self.__reply.sslConfiguration()
+                self.sslConfiguration.emit(sslConfiguration)
+            else:
+                self.clearSslConfiguration.emit()
         
         self.__reply.deleteLater()
         self.__reply = None

eric ide

mercurial