Commit 4688d596 authored by Dan Pascu's avatar Dan Pascu

Account for QPyNullVariant when reading dynamic properties

parent acf56a3b
# Copyright (c) 2010 AG Projects. See LICENSE for details. # Copyright (c) 2010-2013 AG Projects. See LICENSE for details.
# #
__all__ = ['QtDynamicProperty'] __all__ = ['QtDynamicProperty']
from PyQt4.QtCore import QPyNullVariant
class QtDynamicProperty(object): class QtDynamicProperty(object):
def __init__(self, name, type=unicode): def __init__(self, name, type=unicode):
...@@ -11,7 +13,10 @@ class QtDynamicProperty(object): ...@@ -11,7 +13,10 @@ class QtDynamicProperty(object):
def __get__(self, obj, objtype): def __get__(self, obj, objtype):
if obj is None: if obj is None:
return self return self
return obj.property(self.name) value = obj.property(self.name)
if isinstance(value, QPyNullVariant):
value = self.type()
return value
def __set__(self, obj, value): def __set__(self, obj, value):
if value is not None and not isinstance(value, self.type): if value is not None and not isinstance(value, self.type):
value = self.type(value) value = self.type(value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment