-
Notifications
You must be signed in to change notification settings - Fork 22
appmenus: update menus when template_for_dispvms changes #74
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,16 @@ def provides_network_setter(self, vm, event, **kwargs): | |
| self.vm_tasks[vm.name].append( | ||
| asyncio.ensure_future(self.update_appmenus(vm))) | ||
|
|
||
| @qubes.ext.handler('property-set:template_for_dispvms') | ||
| def template_for_dispvms_setter(self, vm, event, **kwargs): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disposable-related menu entries are supposed to be created only if But, with the current version of this PR, when the user sets both the feature and the property (as qubes-vm-settings application does), regenerating will happen twice, in parallel, making QubesOS/qubes-issues#10908 worse. This should ensure regenerating is done only when expected entries change. This means:
|
||
| if vm.app.vmm.offline_mode: | ||
| return | ||
| if not vm.features.get('appmenus-dispvm', False): | ||
| return | ||
| self.collect_done_tasks(vm) | ||
| self.vm_tasks[vm.name].append( | ||
| asyncio.ensure_future(self.update_appmenus(vm))) | ||
|
|
||
| @qubes.ext.handler('property-set:guivm') | ||
| def provides_network_setter(self, vm, event, name, newvalue, oldvalue=None): | ||
| if vm.app.vmm.offline_mode: | ||
|
|
@@ -186,6 +196,8 @@ def provides_network_setter(self, vm, event, name, newvalue, oldvalue=None): | |
| def on_feature_del_appmenus_dispvm(self, vm, event, feature): | ||
| if vm.app.vmm.offline_mode: | ||
| return | ||
| if not getattr(vm, 'template_for_dispvms', False): | ||
| return | ||
| self.collect_done_tasks(vm) | ||
| self.vm_tasks[vm.name].append( | ||
| asyncio.ensure_future(self.update_appmenus(vm))) | ||
|
|
@@ -195,12 +207,14 @@ def on_feature_set_appmenus_dispvm(self, vm, event, feature, | |
| value, oldvalue=None): | ||
| if vm.app.vmm.offline_mode: | ||
| return | ||
| if not getattr(vm, 'template_for_dispvms', False): | ||
| return | ||
| self.collect_done_tasks(vm) | ||
| self.vm_tasks[vm.name].append( | ||
| asyncio.ensure_future(self.update_appmenus(vm))) | ||
|
|
||
| @qubes.ext.handler('domain-feature-set:menu-items') | ||
| def on_feature_set_appmenus_dispvm(self, vm, event, feature, | ||
| def on_feature_set_menu_items(self, vm, event, feature, | ||
| value, oldvalue=None): | ||
| if vm.app.vmm.offline_mode: | ||
| return | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found it - it's here. The
AppmenusExtension()module (and other core-admin extensions) have a trap: they are singletons. The object you create (and modify) here, will survive across all tests. If you need to mockup some of its methods, usemock.patch.object, to undo the change after the test.