Fixed a bug in the message filter causing a traceback when no message filters are configured.

Fri, 01 May 2015 11:27:32 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 01 May 2015 11:27:32 +0200
changeset 4241
545629046c45
parent 4239
4883661fc427
child 4242
2f22ff4951c6

Fixed a bug in the message filter causing a traceback when no message filters are configured.

E5Gui/E5ErrorMessage.py file | annotate | diff | comparison | revisions
E5Network/E5SslCertificatesDialog.py file | annotate | diff | comparison | revisions
E5Network/E5SslErrorHandler.py file | annotate | diff | comparison | revisions
Globals/__init__.py file | annotate | diff | comparison | revisions
Helpviewer/HelpBrowserWV.py file | annotate | diff | comparison | revisions
--- a/E5Gui/E5ErrorMessage.py	Sun Apr 26 16:22:42 2015 +0200
+++ b/E5Gui/E5ErrorMessage.py	Fri May 01 11:27:32 2015 +0200
@@ -55,8 +55,8 @@
         @return flag indicating that the message should be filtered out
             (boolean)
         """
-        for filter in self.settings.value(
-                "MessageFilters", self.__defaultFilters):
+        for filter in Globals.toList(self.settings.value(
+                "MessageFilters", self.__defaultFilters)):
             if filter in message:
                 return True
         
--- a/E5Network/E5SslCertificatesDialog.py	Sun Apr 26 16:22:42 2015 +0200
+++ b/E5Network/E5SslCertificatesDialog.py	Fri May 01 11:27:32 2015 +0200
@@ -25,6 +25,7 @@
 import Preferences
 import Utilities
 import UI.PixmapCache
+import Globals
 
 
 class E5SslCertificatesDialog(QDialog, Ui_E5SslCertificatesDialog):
@@ -67,7 +68,7 @@
         """
         Private slot to populate the server certificates tree.
         """
-        certificateDict = Preferences.toDict(
+        certificateDict = Globals.toDict(
             Preferences.Prefs.settings.value("Ssl/CaCertificatesDict"))
         for server in certificateDict:
             for cert in QSslCertificate.fromData(certificateDict[server]):
@@ -174,7 +175,7 @@
                     self.serversCertificatesTree.indexOfTopLevelItem(parent))
             
             # delete the certificate from the user certificate store
-            certificateDict = Preferences.toDict(
+            certificateDict = Globals.toDict(
                 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict"))
             if server in certificateDict:
                 certs = QSslCertificate.fromData(certificateDict[server])
@@ -202,7 +203,7 @@
         certs = self.__importCertificate()
         if certs:
             server = "*"
-            certificateDict = Preferences.toDict(
+            certificateDict = Globals.toDict(
                 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict"))
             if server in certificateDict:
                 sCerts = QSslCertificate.fromData(certificateDict[server])
@@ -255,7 +256,7 @@
         Private method to update the default SSL configuration.
         """
         caList = self.__getSystemCaCertificates()
-        certificateDict = Preferences.toDict(
+        certificateDict = Globals.toDict(
             Preferences.Prefs.settings.value("Ssl/CaCertificatesDict"))
         for server in certificateDict:
             for cert in QSslCertificate.fromData(certificateDict[server]):
@@ -271,7 +272,7 @@
         
         @return list of system certificates (list of QSslCertificate)
         """
-        caList = QSslCertificate.fromData(Preferences.toByteArray(
+        caList = QSslCertificate.fromData(Globals.toByteArray(
             Preferences.Prefs.settings.value("Help/SystemCertificates")))
         if not caList:
             caList = QSslSocket.systemCaCertificates()
--- a/E5Network/E5SslErrorHandler.py	Sun Apr 26 16:22:42 2015 +0200
+++ b/E5Network/E5SslErrorHandler.py	Fri May 01 11:27:32 2015 +0200
@@ -17,6 +17,7 @@
 
 import Preferences
 import Utilities
+import Globals
 
 
 class E5SslErrorHandler(QObject):
@@ -41,13 +42,13 @@
         caList = self.__getSystemCaCertificates()
         if Preferences.Prefs.settings.contains("Help/CaCertificatesDict"):
             # port old entries stored under 'Help'
-            certificateDict = Preferences.toDict(
+            certificateDict = Globals.toDict(
                 Preferences.Prefs.settings.value("Help/CaCertificatesDict"))
             Preferences.Prefs.settings.setValue(
                 "Ssl/CaCertificatesDict", certificateDict)
             Preferences.Prefs.settings.remove("Help/CaCertificatesDict")
         else:
-            certificateDict = Preferences.toDict(
+            certificateDict = Globals.toDict(
                 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict"))
         for server in certificateDict:
             for cert in QSslCertificate.fromData(certificateDict[server]):
@@ -105,7 +106,7 @@
             default SSL configuration (boolean)
         """
         caMerge = {}
-        certificateDict = Preferences.toDict(
+        certificateDict = Globals.toDict(
             Preferences.Prefs.settings.value("Ssl/CaCertificatesDict"))
         for caServer in certificateDict:
             caMerge[caServer] = QSslCertificate.fromData(
@@ -234,7 +235,7 @@
         
         @return list of system certificates (list of QSslCertificate)
         """
-        caList = QSslCertificate.fromData(Preferences.toByteArray(
+        caList = QSslCertificate.fromData(Globals.toByteArray(
             Preferences.Prefs.settings.value("Ssl/SystemCertificates")))
         if not caList:
             caList = QSslSocket.systemCaCertificates()
--- a/Globals/__init__.py	Sun Apr 26 16:22:42 2015 +0200
+++ b/Globals/__init__.py	Fri May 01 11:27:32 2015 +0200
@@ -12,7 +12,7 @@
 import sys
 import os
 
-from PyQt5.QtCore import QDir, QLibraryInfo
+from PyQt5.QtCore import QDir, QLibraryInfo, QByteArray
 
 # names of the various settings objects
 settingsNameOrganization = "Eric6"
@@ -241,3 +241,64 @@
                     interpreters.append(interpreter)
     
     return interpreters
+
+
+###############################################################################
+## functions for converting QSetting return types to valid types
+###############################################################################
+
+
+def toBool(value):
+    """
+    Module function to convert a value to bool.
+    
+    @param value value to be converted
+    @return converted data
+    """
+    if value in ["true", "1", "True"]:
+        return True
+    elif value in ["false", "0", "False"]:
+        return False
+    else:
+        return bool(value)
+
+
+def toList(value):
+    """
+    Module function to convert a value to a list.
+    
+    @param value value to be converted
+    @return converted data
+    """
+    if value is None:
+        return []
+    elif not isinstance(value, list):
+        return [value]
+    else:
+        return value
+
+
+def toByteArray(value):
+    """
+    Module function to convert a value to a byte array.
+    
+    @param value value to be converted
+    @return converted data
+    """
+    if value is None:
+        return QByteArray()
+    else:
+        return value
+
+
+def toDict(value):
+    """
+    Module function to convert a value to a dictionary.
+    
+    @param value value to be converted
+    @return converted data
+    """
+    if value is None:
+        return {}
+    else:
+        return value
--- a/Helpviewer/HelpBrowserWV.py	Sun Apr 26 16:22:42 2015 +0200
+++ b/Helpviewer/HelpBrowserWV.py	Fri May 01 11:27:32 2015 +0200
@@ -35,6 +35,7 @@
 
 import Preferences
 import UI.PixmapCache
+import Globals
 
 try:
     from PyQt5.QtNetwork import QSslCertificate
@@ -567,7 +568,7 @@
         if not certList:
             return False
         
-        certificateDict = Preferences.toDict(
+        certificateDict = Globals.toDict(
             Preferences.Prefs.settings.value("Ssl/CaCertificatesDict"))
         for server in certificateDict:
             localCAList = QSslCertificate.fromData(certificateDict[server])

eric ide

mercurial