From 7e39a9f6db895413d6c232e7a8068e9e40a05c08 Mon Sep 17 00:00:00 2001 From: jbleyel Date: Tue, 17 Sep 2024 17:39:01 +0200 Subject: [PATCH] [Session] * add onShutdown to call optional onShutdown for each screen if needed [ChannelSelection] * close on shutdown to prevent paint crash --- lib/python/Screens/ChannelSelection.py | 3 +++ lib/python/StartEnigma.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index 085bbb17eee..30d8eda0b75 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -2406,6 +2406,9 @@ def __init__(self, session): self.lastChannelRootTimer.start(100, True) self.pipzaptimer = eTimer() + def onShutdown(self): + self.close() + def asciiOn(self): rcinput = eRCInput.getInstance() rcinput.setKeyboardMode(rcinput.kmAscii) diff --git a/lib/python/StartEnigma.py b/lib/python/StartEnigma.py index 02df9d4eb1b..7db347f317a 100644 --- a/lib/python/StartEnigma.py +++ b/lib/python/StartEnigma.py @@ -58,6 +58,7 @@ def __init__(self, desktop=None, summaryDesktop=None, navigation=None): self.shutdown = False from Components.FrontPanelLed import frontPanelLed frontPanelLed.init(self) + self.allDialogs = [] for plugin in plugins.getPlugins(PluginDescriptor.WHERE_SESSIONSTART): try: @@ -111,8 +112,12 @@ def instantiateDialog(self, screen, *arguments, **kwargs): def deleteDialog(self, screen): screen.hide() screen.doClose() + if screen in self.allDialogs: + self.allDialogs.remove(screen) def deleteDialogWithCallback(self, callback, screen, *retVal): + if screen in self.allDialogs: + self.allDialogs.remove(screen) screen.hide() screen.doClose() if callback is not None: @@ -134,6 +139,7 @@ def doInstantiateDialog(self, screen, arguments, kwargs, desktop): readSkin(dialog, None, dialog.skinName, desktop) # Read skin data. dialog.setDesktop(desktop) # Create GUI view of this dialog. dialog.applySkin() + self.allDialogs.append(dialog) return dialog def pushCurrent(self): @@ -212,6 +218,11 @@ def popSummary(self): if self.summary is not None: self.summary.show() + def onShutdown(self): + for dialog in self.allDialogs: + if hasattr(dialog, "onShutdown"): + dialog.onShutdown() + class PowerKey: """PowerKey code - Handles the powerkey press and powerkey release actions.""" @@ -559,6 +570,7 @@ def runNextScreen(session, screensToRun, *result): print("=" * 100) session.nav.stopService() session.nav.shutdown() + session.onShutdown() VolumeControl.instance.saveVolumeState() configfile.save() from Screens.InfoBarGenerics import saveResumePoints