Skip to content

Commit

Permalink
Merge remote-tracking branch 'qubesos/pr/156'
Browse files Browse the repository at this point in the history
* qubesos/pr/156:
  Fixed incorrect behavior after 'Apply' in Settings
  • Loading branch information
marmarek committed Feb 26, 2019
2 parents 9afa6fa + d23dafe commit 74987f6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion qubesmanager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ def __init__(self, vm, qapp, init_page="basic", parent=None):

self.tabWidget.currentChanged.connect(self.current_tab_changed)

# Initialize several auxillary variables for pylint's sake
self.netvm_idx = None
self.kernel_idx = None
self.label_idx = None
self.template_idx = None
self.root_img_size = None
self.priv_img_size = None
self.default_dispvm_idx = None
self.virt_mode_idx = None
self.virt_mode_list = None

###### basic tab
self.__init_basic_tab__()
self.rename_vm_button.clicked.connect(self.rename_vm)
Expand Down Expand Up @@ -469,6 +480,7 @@ def __apply_basic_tab__(self):
if self.vmlabel.currentIndex() != self.label_idx:
label = self.label_list[self.vmlabel.currentIndex()]
self.vm.label = label
self.label_idx = self.vmlabel.currentIndex()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))

Expand All @@ -477,13 +489,15 @@ def __apply_basic_tab__(self):
if self.template_name.currentIndex() != self.template_idx:
self.vm.template = \
self.template_list[self.template_name.currentIndex()]
self.template_idx = self.template_name.currentIndex()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))

# vm netvm changed
try:
if self.netVM.currentIndex() != self.netvm_idx:
self.vm.netvm = self.netvm_list[self.netVM.currentIndex()]
self.netvm_idx = self.netVM.currentIndex()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))

Expand Down Expand Up @@ -516,6 +530,7 @@ def __apply_basic_tab__(self):
if self.priv_img_size != priv_size:
try:
self.vm.volumes['private'].resize(priv_size * 1024**2)
self.priv_img_size = priv_size
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))

Expand All @@ -524,6 +539,7 @@ def __apply_basic_tab__(self):
if self.root_img_size != sys_size:
try:
self.vm.volumes['root'].resize(sys_size * 1024**2)
self.root_img_size = sys_size
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))

Expand Down Expand Up @@ -773,6 +789,7 @@ def __apply_advanced_tab__(self):
if self.kernel.currentIndex() != self.kernel_idx:
self.vm.kernel = self.kernel_list[
self.kernel.currentIndex()]
self.kernel_idx = self.kernel.currentIndex()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))

Expand All @@ -781,12 +798,14 @@ def __apply_advanced_tab__(self):
if self.default_dispvm.currentIndex() != self.default_dispvm_idx:
self.vm.default_dispvm = \
self.default_dispvm_list[self.default_dispvm.currentIndex()]
self.default_dispvm_idx = self.default_dispvm.currentIndex()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))

try:
if self.virt_mode.currentIndex() != self.virt_mode_idx:
self.vm.virt_mode = self.selected_virt_mode()
self.virt_mode_idx = self.virt_mode.currentIndex()
except Exception as ex: # pylint: disable=broad-except
msg.append(str(ex))

Expand Down Expand Up @@ -854,7 +873,6 @@ def update_virt_mode_list(self):

self.virt_mode.clear()

# pylint: disable=attribute-defined-outside-init
self.virt_mode_list, self.virt_mode_idx = utils.prepare_choice(\
self.virt_mode, self.vm, 'virt_mode', choices, None,\
allow_default=True, transform=(lambda x: str(x).upper()))
Expand Down

0 comments on commit 74987f6

Please sign in to comment.