Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gprevot opened this issue Oct 1, 2020 · 1 comment

Comments

@gprevot
Copy link

gprevot commented Oct 1, 2020

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)

@picca
Copy link
Collaborator

picca commented Jun 16, 2022

Hello Pierre, do you think that this analyse is right.
It seems that it is in fact in guidata and not guiqwt

this bug was reported by one of our user whom developed a gui for xrd data treatement.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants