summaryrefslogtreecommitdiffstats
path: root/iw
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2006-11-01 19:54:51 +0000
committerChris Lumens <clumens@redhat.com>2006-11-01 19:54:51 +0000
commit11826a6b61822b434a9fc37f2c33b7c6a6761596 (patch)
tree0f1324e254232eea5ce61ee2eb690705ac8206c4 /iw
parent95c30157a231b9b37d671d3f5d057ff1e3dc0f2e (diff)
downloadanaconda-11826a6b61822b434a9fc37f2c33b7c6a6761596.tar.gz
anaconda-11826a6b61822b434a9fc37f2c33b7c6a6761596.tar.xz
anaconda-11826a6b61822b434a9fc37f2c33b7c6a6761596.zip
Always set an active value on the peCombo, and don't traceback if the default
value is the first one in the list (#212317).
Diffstat (limited to 'iw')
-rw-r--r--iw/lvm_dialog_gui.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/iw/lvm_dialog_gui.py b/iw/lvm_dialog_gui.py
index 319b801b6..730654f6a 100644
--- a/iw/lvm_dialog_gui.py
+++ b/iw/lvm_dialog_gui.py
@@ -241,25 +241,23 @@ class VolumeGroupEditor:
def createPEOptionMenu(self, default=4096):
peCombo = datacombo.DataComboBox()
- idx = 0
- defindex = None
- actualPE = lvm.getPossiblePhysicalExtents(floor=1024)
- for curpe in actualPE:
- # dont show PE over 128M, unless it's the default
- if curpe > 131072 and curpe != default:
- continue
-
+ actualPE = lvm.getPossiblePhysicalExtents(floor=1024)
+ for curpe in actualPE:
+ # don't show PE over 128M, unless it's the default
+ if curpe > 131072 and curpe != default:
+ continue
+
val = self.prettyFormatPESize(curpe)
peCombo.append(val, curpe)
- if default == curpe:
- defindex = idx
-
- idx = idx + 1
-
- if defindex:
- peCombo.set_active(defindex)
+ # First try to set the combo's active value to the default we're
+ # passed. If that doesn't work, just set it to the first one to
+ # prevent TypeErrors everywhere.
+ try:
+ peCombo.set_active(actualPE.index(default))
+ except ValueError:
+ peCombo.set_active(0)
peCombo.set_data("lastidx", peCombo.get_active())
peCombo.connect("changed", self.peChangeCB)