From bffd256734d3238a67c4725c3a8c78cf21239dad Mon Sep 17 00:00:00 2001 From: Maxime Perrotin Date: Thu, 16 May 2019 10:07:10 +0100 Subject: [PATCH] Workaround pyside bug --- README.md | 1 + asn1_value_editor/asn1_value_editor.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d54044a..618a584 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/asn1_value_editor/asn1_value_editor.py b/asn1_value_editor/asn1_value_editor.py index a20a8b0..9867a3a 100755 --- a/asn1_value_editor/asn1_value_editor.py +++ b/asn1_value_editor/asn1_value_editor.py @@ -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() -- GitLab