You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to rework the USB dependencies I found an issue when using menuconfigs in named choice overrides in kconfigs menuconfig feature. The result is a crash when going back from the overridden (or additional) menuconfig from the named choice override.
Steps to reproduce the issue
To isolate the problem one can add the following file:
Running python menuconfig.py, navigate to the BAZ option so that the BOOP symbol is visible.
Exit out of the menu twice so that you see the FOO page.
Expected results
For it to go back to the last selected item.
Actual results
an error resulting in:
Using default symbol values (no '.config')
Traceback (most recent call last):
File "menuconfig.py", line 3289, in <module>
_main()
File "menuconfig.py", line 663, in _main
menuconfig(standard_kconfig(__doc__))
File "menuconfig.py", line 732, in menuconfig
print(curses.wrapper(_menuconfig))
File "/usr/lib/python3.8/curses/__init__.py", line 105, in wrapper
return func(stdscr, *args, **kwds)
File "menuconfig.py", line 891, in _menuconfig
_leave_menu()
File "menuconfig.py", line 1206, in _leave_menu
_sel_node_i = _shown.index(_cur_menu)
ValueError: <menu node for choice IMPLEMENTATION, deps y, has child, has next, Kconfig:40> is not in list
Additional Notes
This is not the first time we saw an issue here, as this was open upstream due to this bug ulfalizer/Kconfiglib#94
However, it resets the context and does not keep the same position when going back.
Proposed Solution
The issue actually seems to stem from the creation of the kconfig tree. The parent of the overridden or additional menu does not have surrounding context. Looking deep I actually see the parent, in this case, going to the top menu as the dependencies are not propagated in that logic.
When the menuconfig tries to figure out the position it must be at when going back, it fails since the actual node object of the overridden named choice is not a part of the shown objects... Thus, trying to find the index fails.
By adding following snippet to kconfiglib.py I was able to give the overridden nodes a proper parent using the name of the named choice for matching...
self._init(filename, warn, warn_to_stderr, encoding)
# Add parents of stray named choicesforchoiceinself.named_choices.values():
parent=Nonefornodeinchoice.nodes:
ifnode.prompt:
parent=node.parentbreakfornodeinchoice.nodes:
ifnotnode.prompt:
node.parent=parent
This would require a bit more logic when looking this stuff up in menuconfig.py
Description
While trying to rework the USB dependencies I found an issue when using
menuconfig
s in named choice overrides in kconfigsmenuconfig
feature. The result is a crash when going back from the overridden (or additional) menuconfig from the named choice override.Steps to reproduce the issue
To isolate the problem one can add the following file:
dist/tools/kconfiglib/Kconfig
Running
![Peek 2022-12-21 12-51](https://user-images.githubusercontent.com/19396439/208899133-c7600652-14bd-4dac-adcd-1e3570e899ed.gif)
python menuconfig.py
, navigate to theBAZ
option so that theBOOP
symbol is visible.Exit out of the menu twice so that you see the
FOO
page.Expected results
For it to go back to the last selected item.
Actual results
an error resulting in:
Additional Notes
This is not the first time we saw an issue here, as this was open upstream due to this bug ulfalizer/Kconfiglib#94
However, it resets the context and does not keep the same position when going back.
Proposed Solution
The issue actually seems to stem from the creation of the kconfig tree. The parent of the overridden or additional menu does not have surrounding context. Looking deep I actually see the parent, in this case, going to the top menu as the dependencies are not propagated in that logic.
When the menuconfig tries to figure out the position it must be at when going back, it fails since the actual node object of the overridden named choice is not a part of the shown objects... Thus, trying to find the index fails.
By adding following snippet to
kconfiglib.py
I was able to give the overridden nodes a proper parent using the name of the named choice for matching...This would require a bit more logic when looking this stuff up in
menuconfig.py
Since the items match the in the list it works, it is just the the node objects that don't...
Probably there is a better way of handling this, likey something to do with only checking the items or improvements in the
kconfiglib.py
.This seems to work for my use case but I can't help but wonder if
The text was updated successfully, but these errors were encountered: