Skip to content

Commit

Permalink
Fix detecting if widget was changed in VM settings
Browse files Browse the repository at this point in the history
Instead of checking for isVisible, which can fail if
we are on a different tab, check for isEnabled (also
added appropriate disable commands where widget should
be disabled).

fixes QubesOS/qubes-issues#7990
  • Loading branch information
marmarta committed Feb 2, 2023
1 parent bafa70f commit ae5d2fb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions qubesmanager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ def __init_basic_tab__(self):
except qubesadmin.exc.QubesDaemonAccessError:
self.autostart_vm.setEnabled(False)
except AttributeError:
self.autostart_vm.setEnabled(False)
self.autostart_vm.setVisible(False)

# type
Expand Down Expand Up @@ -540,9 +541,8 @@ def __apply_basic_tab__(self):

# vm label changed
try:
if self.vmlabel.isVisible():
if utils.did_widget_selection_change(self.vmlabel):
self.vm.label = self.vmlabel.currentData()
if utils.did_widget_selection_change(self.vmlabel):
self.vm.label = self.vmlabel.currentData()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))

Expand Down Expand Up @@ -571,7 +571,7 @@ def __apply_basic_tab__(self):

# autostart_vm
try:
if self.autostart_vm.isVisible():
if self.autostart_vm.isEnabled():
if self.vm.autostart != self.autostart_vm.isChecked():
self.vm.autostart = self.autostart_vm.isChecked()
except qubesadmin.exc.QubesException as ex:
Expand Down Expand Up @@ -827,7 +827,9 @@ def __init_advanced_tab__(self):
self.kernel_opts.setText(getattr(self.vm, 'kernelopts', '-'))
except qubesadmin.exc.QubesDaemonAccessError:
self.kernel_groupbox.setVisible(False)
self.kernel.setEnabled(False)
else:
self.kernel.setEnabled(False)
self.kernel_groupbox.setVisible(False)

if not hasattr(self.vm, 'default_dispvm'):
Expand Down Expand Up @@ -887,6 +889,7 @@ def __init_advanced_tab__(self):
self.run_in_debug_mode.setVisible(True)
except AttributeError:
self.run_in_debug_mode.setVisible(False)
self.run_in_debug_mode.setEnabled(False)

utils.initialize_widget(
widget=self.allow_fullscreen,
Expand Down Expand Up @@ -958,7 +961,7 @@ def __apply_advanced_tab__(self):
msg.append(str(ex))

# in case VM is not Linux
if hasattr(self.vm, "kernel") and self.kernel_groupbox.isVisible():
if hasattr(self.vm, "kernel"):
try:
if utils.did_widget_selection_change(self.kernel):
self.vm.kernel = self.kernel.currentData()
Expand Down Expand Up @@ -999,7 +1002,7 @@ def __apply_advanced_tab__(self):

# run_in_debug_mode
try:
if self.run_in_debug_mode.isVisible():
if self.run_in_debug_mode.isEnabled():
if self.vm.debug != self.run_in_debug_mode.isChecked():
self.vm.debug = self.run_in_debug_mode.isChecked()
except qubesadmin.exc.QubesException as ex:
Expand Down

0 comments on commit ae5d2fb

Please sign in to comment.