harvesters_gui icon indicating copy to clipboard operation
harvesters_gui copied to clipboard

Crash when writing to IInteger node that defines range larger than int32 in Attribute Controller

Open basfee opened this issue 1 year ago • 3 comments

Describe the bug When trying to write to an IInteger node that defines a range larger than int32 (via the Attribute Controller window), the GUI will crash as soon as you double click the field where the value is to be filled in. I found this in an Integer node that defines the following range:

        <Integer Name="x">
            <pValue>Reg_x</pValue>
            <Min>0</Min>
            <Max>4294967295</Max>
        </Integer>

The crash message is:

WARNING: Traceback (most recent call last):
  File "XXX/lib/python3.8/site-packages/harvesters_gui/_private/frontend/pyqt5/feature_tree.py", line 339, in createEditor
    w.setRange(feature.min, feature.max)
OverflowError: argument 2 overflowed: value must be in the range -2147483648 to 2147483647
Aborted (core dumped)

To Reproduce Steps to reproduce the behavior:

  1. Start harvesters GUI, connect to a camera with an IInteger node with range > int32
  2. Open the Attribute Controller window
  3. Go to the troublesome IInteger node and double click the value, such that you can write your own value
  4. Crash on the double click (never get a chance to input a value)

Expected behavior No crash, expecting compatibility with 64-bit int

Desktop:

  • OS: Ubuntu 20
  • Version: 1.3.8

Additional information The problem is that the QSpinBox object used in the GUI is limited to int32: https://doc.qt.io/qt-5/qspinbox.html#maximum-prop but per the GenICam standard (I'm looking at v2.1.1) an integer node its range is 64-bits.

basfee avatar Jul 06 '23 08:07 basfee

Hi, I happened to run into this crash also and have been using this commit as a fix.

Have been meaning to get a PR created for this, but just hadn't done it yet. I'm curious to know if this fixes the issues you're seeing. Thanks!

cgraf78 avatar Jul 06 '23 12:07 cgraf78

Hey. I have tested your changes and indeed they fix this issue! Wonderful.

Note: there are some differences though. Currently, the box refuses to have non-numeric characters in the box and it also doesn't allow setting the box empty (it keeps the previous value when the box is made empty and enter is pressed).

With the changes the harvesters-gui crashes instead for such cases, with:

WARNING: Traceback (most recent call last):
  File "XXX/lib/python3.8/site-packages/harvesters_gui/_private/frontend/pyqt5/feature_tree.py", line 400, in setModelData
    data = editor.value()
  File "XXX/lib/python3.8/site-packages/harvesters_gui/_private/frontend/pyqt5/big_int_spinbox.py", line 41, in value
    return int(self.lineEdit.text())
ValueError: invalid literal for int() with base 10: ''

basfee avatar Jul 07 '23 12:07 basfee

Good news, progress! Thanks for testing.

Yeah, the changes in this commit are probably still a bit rough and need a bit more rigor. I'll try to look at the additional issues found with your testing... appreciate you flagging these.

cgraf78 avatar Jul 08 '23 01:07 cgraf78