Skip to content

Problem of recursivity when using callbacks with several ChoiceItem instances in a DataSet instance #85

@gprevot

Description

@gprevot

I have found a problem of recursivity in the guidata code (version '1.7.6') when using DataSet instances with two or more ChoiceItem instances that have associated callbacks. This is due to the call to self.index_changed within self.get in the class ChoiceWidget(AbstractDataSetWidget). It is easily corrected by interverting the two following lines in qtitemwidgets.py, lines 743-744:

self.index_changed(idx)
self._first_call = False

in the present code, self.index_changed for a first ChoiceWidget leads to a change to a second ChoiceWidget that induces a change to the first ChoiceWidget before self._first_call has been set to False.

the whole function should be rewritten as:
def get(self):
"""Override AbstractDataSetWidget method"""
self.initialize_widget()
value = self.item.get()
if value is not None:
idx = 0
_choices = self.item.get_prop_value("data", "choices")
for key, _val, _img in _choices:
if key == value:
break
idx += 1
self.set_widget_value(idx)
if self._first_call:
self._first_call = False
self.index_changed(idx)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions