Commit dd074fea authored by Maxime Perrotin's avatar Maxime Perrotin

Work on the support of optional fields

parent b9f5256e
......@@ -34,6 +34,7 @@ LICENSE: LGPL - see LICENSE file
CHANGELOG:
1.7.1 - Enable support for optional fields
1.7.0 - Optional fields and fix segfaults when updating CHOICE fields
1.6.9 - Add basic support for optional fields
1.6.7 - Fix CPU usage of polling thread
......
......@@ -16,7 +16,7 @@
__author__ = "Maxime Perrotin"
__license__ = "LGPLv3"
__version__ = "1.7.0"
__version__ = "1.7.1"
__url__ = "https://taste.tools"
import sys
......@@ -420,7 +420,7 @@ class asn1Editor(QTreeView):
dest.Reset(stateBefore)
# Check if field is optional and set the .exist.field
# accordingly
field_root = root.child(i)
#field_root = root.child(i)
field_name = \
root.child(i, 0).text().replace('-', '_')
field_optionality = root.child(i, 4)
......@@ -428,10 +428,10 @@ class asn1Editor(QTreeView):
and field_optionality.isCheckable():
present = field_optionality.checkState() == Qt.Checked
print field_name, "SET" if present else "UNSET"
# Uncomment the following when Stubs.py supports it:
#ptr = getattr(dest, "exist")
#ptr = getattr(ptr, field_name)
#ptr.Set (1 if present else 0)
# Set the "exist" value for optional fields
ptr = getattr(dest, "exist")
ptr = getattr(ptr, field_name)
ptr.Set (1 if present else 0)
dest.Reset(stateBefore)
......@@ -574,6 +574,22 @@ class asn1Editor(QTreeView):
fillRow(root, i, ptr, seqOf=seqOf)
ptr.Reset(stateBefore)
# check if field is optional and set checkbox from value
field_name = \
root.child(i, 0).text().replace('-', '_')
field_optionality = root.child(i, 4)
if field_optionality.data(OPTIONAL) \
and field_optionality.isCheckable():
# Set the "exist" value for optional fields
ptr = getattr(ptr, "exist")
ptr = getattr(ptr, field_name)
present = ptr.Get()
print field_name, field_optionality.data(OPTIONAL), present
field_optionality.setCheckState (Qt.Checked if present
else Qt.Unchecked)
ptr.Reset(stateBefore)
def updateVariable(self, root=None, asn1Var=None):
''' Update the variable value (when loading a TC or receiving a TM) '''
root = root or self.treeItem
......
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