Commit bffd2567 authored by Maxime Perrotin's avatar Maxime Perrotin

Workaround pyside bug

parent f0ce3c84
......@@ -34,6 +34,7 @@ LICENSE: LGPL - see LICENSE file
CHANGELOG:
1.7.7 - Workaround pyside bug raising Overflow error for 64 bits numbers
1.7.5 - Better compatibility with old versions of DMT not supporting Optional fields
1.7.4 - Bugfix for opengeode simulator
1.7.3 - Support optionality in standalone editor too
......
......@@ -16,7 +16,7 @@
__author__ = "Maxime Perrotin"
__license__ = "LGPLv3"
__version__ = "1.7.6"
__version__ = "1.7.7"
__url__ = "https://taste.tools"
import sys
......@@ -403,7 +403,7 @@ class asn1Editor(QTreeView):
intMappings = root.child(i, 3).data(INTMAP)
for enumerant, num in intMappings.viewitems():
if enumerant == value:
ptr.Set(num)
ptr.Set(int(num))
break
else:
raise TypeError('ENUMERATED value not found')
......@@ -462,7 +462,7 @@ class asn1Editor(QTreeView):
intMappings = self.model.item(row, 3).data(INTMAP)
for enumerant, num in intMappings.viewitems():
if enumerant == value:
dest.Set(num)
dest.Set(int(num))
break
else:
self.log.error('Missing enumerted or bug - please report')
......@@ -525,7 +525,7 @@ class asn1Editor(QTreeView):
value = ptr.Get()
intMappings = child.data(INTMAP)
for enumerant, num in intMappings.viewitems():
if num == value:
if int(num) == value:
child.setText(enumerant)
break
else:
......@@ -646,7 +646,7 @@ class asn1Editor(QTreeView):
for enumerant, num in intMappings.viewitems():
# XXX if value is not initialized and no enum has value 0
# an error will be raised
if num == value:
if int(num) == value:
self.model.item(row, 3).setText(enumerant)
break
else:
......@@ -955,7 +955,12 @@ class asn1Editor(QTreeView):
# Define type attributes, later used to define the proper cell editor
val.setData(elem["type"], ASN1TYPE) # type (ENUMERATED)
val.setData(elem["values"], CHOICE_LIST) # enum values
val.setData(elem["valuesInt"], INTMAP) # mapping name - value
# Due to a bug in Pyside, there can be an OverflowError raised if the
# enumerated value cannot fit in 32 bits storage. To workaround, the
# value is tranformed o a string.
workaround = {a:str(b) for a, b in elem['valuesInt'].viewitems()}
val.setData(workaround, INTMAP) # mapping name - value
#val.setData(elem["valuesInt"], INTMAP) # mapping name - value
constraint = QStandardItem()
present = QStandardItem()
......
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