From 1101fc3f4349fbdbed94e82870aae6b4af9312fe Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 4 Nov 2008 11:30:56 +0100 Subject: more failsave code, remove imho unneeded invalidate calls --- lib/python/Screens/TimerEdit.py | 47 ++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'lib/python/Screens/TimerEdit.py') diff --git a/lib/python/Screens/TimerEdit.py b/lib/python/Screens/TimerEdit.py index 67c49cc5..800bab33 100644 --- a/lib/python/Screens/TimerEdit.py +++ b/lib/python/Screens/TimerEdit.py @@ -117,41 +117,40 @@ class TimerEditList(Screen): self.session.nav.RecordTimer.timeChanged(t) self.refill() self.updateState() - + + def removeAction(self, descr): + actions = self["actions"].actions + if descr in actions: + del actions[descr] + def updateState(self): cur = self["timerlist"].getCurrent() if cur: if self.key_red_choice != self.DELETE: self["actions"].actions.update({"red":self.removeTimerQuestion}) self["key_red"].setText(_("Delete")) - self["key_red"].instance.invalidate() self.key_red_choice = self.DELETE if cur.disabled and (self.key_yellow_choice != self.ENABLE): self["actions"].actions.update({"yellow":self.toggleDisabledState}) self["key_yellow"].setText(_("Enable")) - self["key_yellow"].instance.invalidate() self.key_yellow_choice = self.ENABLE elif cur.isRunning() and not cur.repeated and (self.key_yellow_choice != self.EMPTY): - del self["actions"].actions["yellow"] + self.removeAction("yellow") self["key_yellow"].setText(" ") - self["key_yellow"].instance.invalidate() self.key_yellow_choice = self.EMPTY elif ((not cur.isRunning())or cur.repeated ) and (not cur.disabled) and (self.key_yellow_choice != self.DISABLE): self["actions"].actions.update({"yellow":self.toggleDisabledState}) self["key_yellow"].setText(_("Disable")) - self["key_yellow"].instance.invalidate() self.key_yellow_choice = self.DISABLE else: if self.key_red_choice != self.EMPTY: - del self["actions"].actions["red"] + self.removeAction("red") self["key_red"].setText(" ") - self["key_red"].instance.invalidate() self.key_red_choice = self.EMPTY if self.key_yellow_choice != self.EMPTY: - del self["actions"].actions["yellow"] + self.removeAction("yellow") self["key_yellow"].setText(" ") - self["key_yellow"].instance.invalidate() self.key_yellow_choice = self.EMPTY showCleanup = True @@ -164,15 +163,12 @@ class TimerEditList(Screen): if showCleanup and (self.key_blue_choice != self.CLEANUP): self["actions"].actions.update({"blue":self.cleanupQuestion}) self["key_blue"].setText(_("Cleanup")) - self["key_blue"].instance.invalidate() self.key_blue_choice = self.CLEANUP elif (not showCleanup) and (self.key_blue_choice != self.EMPTY): - del self["actions"].actions["blue"] + self.removeAction("blue") self["key_blue"].setText(" ") - self["key_blue"].instance.invalidate() self.key_blue_choice = self.EMPTY - def fillTimerList(self): del self.list[:] @@ -399,23 +395,25 @@ class TimerSanityConflict(Screen): def down(self): self["list"].instance.moveSelection(self["list"].instance.moveDown) self["timer2"].moveToIndex(self["list"].getSelectedIndex()) - + + def removeAction(self, descr): + actions = self["actions"].actions + if descr in actions: + del actions[descr] + def updateState(self): if self.timer[0] is not None: if self.timer[0].disabled and self.key_green_choice != self.ENABLE: self["actions"].actions.update({"green":self.toggleTimer1}) self["key_green"].setText(_("Enable")) - self["key_green"].instance.invalidate() self.key_green_choice = self.ENABLE elif self.timer[0].isRunning() and not timer[0].repeated and self.key_green_choice != self.EMPTY: - del self["actions"].actions["green"] + self.removeAction("green") self["key_green"].setText(" ") - self["key_green"].instance.invalidate() self.key_green_choice = self.EMPTY elif (not self.timer[0].isRunning() or self.timer[0].repeated ) and self.key_green_choice != self.DISABLE: self["actions"].actions.update({"green":self.toggleTimer1}) self["key_green"].setText(_("Disable")) - self["key_green"].instance.invalidate() self.key_green_choice = self.DISABLE if len(self.timer) > 1: x = self["list"].getSelectedIndex() @@ -423,25 +421,20 @@ class TimerSanityConflict(Screen): if self.timer[x].disabled and self.key_blue_choice != self.ENABLE: self["actions"].actions.update({"blue":self.toggleTimer2}) self["key_blue"].setText(_("Enable")) - self["key_blue"].instance.invalidate() self.key_blue_choice = self.ENABLE elif self.timer[x].isRunning() and not timer[x].repeated and self.key_blue_choice != self.EMPTY: - del self["actions"].actions["blue"] + self.removeAction("blue") self["key_blue"].setText(" ") - self["key_blue"].instance.invalidate() self.key_blue_choice = self.EMPTY elif (not self.timer[x].isRunning() or self.timer[x].repeated ) and self.key_blue_choice != self.DISABLE: self["actions"].actions.update({"blue":self.toggleTimer2}) self["key_blue"].setText(_("Disable")) - self["key_blue"].instance.invalidate() self.key_blue_choice = self.DISABLE else: #FIXME.... this doesnt hide the buttons self.... just the text - del self["actions"].actions["yellow"] + self.removeAction("yellow") self["key_yellow"].setText(" ") - self["key_yellow"].instance.invalidate() self.key_yellow_choice = self.EMPTY - del self["actions"].actions["blue"] + self.removeAction("blue") self["key_blue"].setText(" ") - self["key_blue"].instance.invalidate() self.key_blue_choice = self.EMPTY -- cgit v1.2.3 From 613447d89ad124aa6fb52627dd7c98085cdd8d31 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 7 Nov 2008 14:38:00 +0100 Subject: fix bsod in some cases --- lib/python/Screens/TimerEdit.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'lib/python/Screens/TimerEdit.py') diff --git a/lib/python/Screens/TimerEdit.py b/lib/python/Screens/TimerEdit.py index 800bab33..aae345db 100644 --- a/lib/python/Screens/TimerEdit.py +++ b/lib/python/Screens/TimerEdit.py @@ -317,6 +317,7 @@ class TimerSanityConflict(Screen): EMPTY = 0 ENABLE = 1 DISABLE = 2 + EDIT = 3 def __init__(self, session, timer): Screen.__init__(self, session) @@ -338,10 +339,11 @@ class TimerSanityConflict(Screen): self["key_red"] = Button("Edit") self["key_green"] = Button(" ") - self["key_yellow"] = Button("Edit") + self["key_yellow"] = Button(" ") self["key_blue"] = Button(" ") self.key_green_choice = self.EMPTY + self.key_yellow_choice = self.EMPTY self.key_blue_choice = self.EMPTY self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ShortcutActions", "TimerEditActions"], @@ -415,9 +417,14 @@ class TimerSanityConflict(Screen): self["actions"].actions.update({"green":self.toggleTimer1}) self["key_green"].setText(_("Disable")) self.key_green_choice = self.DISABLE + if len(self.timer) > 1: x = self["list"].getSelectedIndex() if self.timer[x] is not None: + if self.key_yellow_choice == self.EMPTY: + self["actions"].actions.update({"yellow":self.editTimer2}) + self["key_yellow"].setText(_("Edit")) + self.key_yellow_choice = self.EDIT if self.timer[x].disabled and self.key_blue_choice != self.ENABLE: self["actions"].actions.update({"blue":self.toggleTimer2}) self["key_blue"].setText(_("Enable")) @@ -432,9 +439,11 @@ class TimerSanityConflict(Screen): self.key_blue_choice = self.DISABLE else: #FIXME.... this doesnt hide the buttons self.... just the text - self.removeAction("yellow") - self["key_yellow"].setText(" ") - self.key_yellow_choice = self.EMPTY - self.removeAction("blue") - self["key_blue"].setText(" ") - self.key_blue_choice = self.EMPTY + if self.key_yellow_choice != self.EMPTY: + self.removeAction("yellow") + self["key_yellow"].setText(" ") + self.key_yellow_choice = self.EMPTY + if self.key_blue_choice != self.EMPTY: + self.removeAction("blue") + self["key_blue"].setText(" ") + self.key_blue_choice = self.EMPTY -- cgit v1.2.3