-
Notifications
You must be signed in to change notification settings - Fork 15
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
fix: Fix recursion check in Qt6 #232
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #232 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 31 31
Lines 1916 1914 -2
=========================================
- Hits 1916 1914 -2 ☔ View full report in Codecov by Sentry. |
looking at my note again, it looks like I was working around this limitation:
it looks like that was true in Qt 6.1 ... probably when I was adding support for this. But the Can you check to see if simply removing that for action in actions:
if isinstance(action, QMenuItemAction):
action.update_from_context(ctx)
elif isinstance(menu := action.menu(), QModelMenu):
menu.update_from_context(ctx) perhaps we don't need to be careful about recursion on the |
I didn't know the menu() method returned! Yes, it worked as expected. |
I agree that it should be tested, but if I understand your problem statement that " the enablement expression of an action at app-model/tests/test_qt/test_qmenu.py Lines 89 to 103 in a0d95b1
those tests are asserting that the enablement of a submenu does change based on the context provided to the parent menu. can you help determine what might be different about the case you found that was broken>? |
sorry if I didn't make it clear, but what I meant in |
ok, I added a test that I think tests that in b59383c (it checks the enablement of an action inside of submenu is still controlled by the context). However, it also passes on main, without this PR ... so I'm still not sure I'm hitting the case you found? |
Thank you for making the test! OS: Windows 11
|
Ok great! I must have made a mistake when I tried to test it on main. Thanks |
The current implementation of the menu context updates for Qt6 (the "FIXME" part) will skip all the nested submenus. For example, the
enablement
expression of an action atFile > XXX > Run YYY
will be ignored (= always enabled).This PR fixes this problem by using the
_skip: QModelMenu
argument to avoid running_update_from_context
on the same menu. I checked that this works on my personal app, but I don't know if it is safe in other use cases.I think whether submenus are updated properly should be included in the test, but I cannot fully understand the FullApp pytest fixture (such as when each action is supposed to be enabled). Could you please help me with adding this test if it's reasonable to be added?