← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~mzibricky/openlp/bug-1095268 into lp:openlp

 

matysek has proposed merging lp:~mzibricky/openlp/bug-1095268 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1095268 in OpenLP: "issue with 'QPyNullVariant' in parsing settings"
  https://bugs.launchpad.net/openlp/+bug/1095268

For more details, see:
https://code.launchpad.net/~mzibricky/openlp/bug-1095268/+merge/141598

This fixes the related bug with QPyNullVariant.
-- 
https://code.launchpad.net/~mzibricky/openlp/bug-1095268/+merge/141598
Your team OpenLP Core is requested to review the proposed merge of lp:~mzibricky/openlp/bug-1095268 into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2012-12-29 20:56:56 +0000
+++ openlp/core/lib/__init__.py	2013-01-02 11:30:29 +0000
@@ -141,10 +141,21 @@
         if defaultValue is None and not super(Settings, self).contains(key):
             return None
         setting =  super(Settings, self).value(key, defaultValue)
-        # An empty list saved to the settings results in a None type being
-        # returned.
+        # On OS X (and probably on other platforms too) empty value from QSettings
+        # is represented as type PyQt4.QtCore.QPyNullVariant. This type has to be
+        # converted to proper 'None' Python type.
+        if isinstance(setting, QtCore.QPyNullVariant) and setting.isNull():
+            setting = None
+        # Handle 'None' type (empty value) properly.
         if setting is None:
-            return []
+            # An empty string saved to the settings results in a None type being
+            # returned. Convert it to empty unicode string.
+            if isinstance(defaultValue, unicode):
+                return u''
+            # An empty list saved to the settings results in a None type being
+            # returned.
+            else:
+                return []
         # Convert the setting to the correct type.
         if isinstance(defaultValue, bool):
             if isinstance(setting, bool):


Follow ups