src/eric7/UI/UserInterface.py

branch
eric7
changeset 11215
d07c71a34adf
parent 11207
7193db06924d
child 11216
a1471981ef18
--- a/src/eric7/UI/UserInterface.py	Thu Apr 10 18:36:24 2025 +0200
+++ b/src/eric7/UI/UserInterface.py	Thu Apr 10 18:39:29 2025 +0200
@@ -144,6 +144,7 @@
         password has been changed with the old and the new password
     @signal onlineStateChanged(online) emitted to indicate a change of the
         network state
+    @signal shutdown() emitted to indicate a shutdown of the application
     """
 
     appendStderr = pyqtSignal(str)
@@ -153,6 +154,7 @@
     showMenu = pyqtSignal(str, QMenu)
     mainPasswordChanged = pyqtSignal(str, str)
     onlineStateChanged = pyqtSignal(bool)
+    shutdown = pyqtSignal()
 
     maxFilePathLen = 100
     maxMenuFilePathLen = 75
@@ -664,7 +666,7 @@
 
         self.currentProfile = None
 
-        self.shutdownCalled = False
+        self.__shutdownCalled = False
         self.inCloseEvent = False
 
         # now fire up the single application server
@@ -809,11 +811,11 @@
 
         # Create previewer
         logging.getLogger(__name__).debug("Creating Previewer...")
-        self.__previewer = Previewer(self.viewmanager)
+        self.__previewer = Previewer(viewmanager=self.viewmanager, ui=self)
 
         # Create AST viewer
         logging.getLogger(__name__).debug("Creating Python AST Viewer")
-        self.__astViewer = PythonAstViewer(self.viewmanager)
+        self.__astViewer = PythonAstViewer(viewmanager=self.viewmanager, ui=self)
 
         # Create DIS viewer
         logging.getLogger(__name__).debug("Creating Python Disassembly Viewer")
@@ -851,7 +853,7 @@
             logging.getLogger(__name__).debug("Creating Template Viewer...")
             from eric7.Templates.TemplateViewer import TemplateViewer  # noqa: I-101
 
-            self.templateViewer = TemplateViewer(None, self.viewmanager)
+            self.templateViewer = TemplateViewer(self, self.viewmanager)
         else:
             logging.getLogger(__name__).debug("Template Viewer disabled")
             self.templateViewer = None
@@ -8433,7 +8435,7 @@
         @return flag indicating success
         @rtype bool
         """
-        if self.shutdownCalled:
+        if self.__shutdownCalled:
             return True
 
         if not self.viewmanager.checkAllDirty():
@@ -8447,8 +8449,6 @@
 
         sessionCreated = self.__writeSession()
 
-        self.__astViewer.hide()
-
         self.shell.closeShell()
 
         if not self.project.closeProject(shutdown=True):
@@ -8467,37 +8467,12 @@
         if sessionCreated and not self.__disableCrashSession:
             self.__deleteCrashSession()
 
-        if self.codeDocumentationViewer is not None:
-            self.codeDocumentationViewer.shutdown()
-
-        self.__previewer.shutdown()
-
-        self.__astViewer.shutdown()
-
         self.__writeTasks()
 
-        if self.templateViewer is not None:
-            self.templateViewer.save()
-
         if not self.debuggerUI.shutdownServer():
             return False
-        self.debuggerUI.shutdown()
-
-        self.backgroundService.shutdown()
-
-        if self.cooperation is not None:
-            self.cooperation.shutdown()
-
-        if self.__helpViewerWidget is not None:
-            self.__helpViewerWidget.shutdown()
-
-        if self.microPythonWidget is not None:
-            self.microPythonWidget.shutdown()
-
-        self.pipInterface.shutdown()
-
-        self.pluginManager.doShutdown()
-
+
+        # stop the single application server
         if self.SAServer is not None:
             self.SAServer.shutdown()
             self.SAServer = None
@@ -8516,7 +8491,10 @@
         self.__saveCurrentViewProfile(True)
         Preferences.saveToolGroups(self.toolGroups, self.currentToolGroup)
         Preferences.syncPreferences()
-        self.shutdownCalled = True
+
+        # emit the shutdown() signal to allow connected parts to perform their
+        # individual shutdown actions
+        self.shutdown.emit()
 
         # shut down the global file system watcher
         EricFileSystemWatcher.instance().shutdown()
@@ -8525,6 +8503,8 @@
         sys.stdout = sys.__stdout__
         sys.stderr = sys.__stderr__
 
+        self.__shutdownCalled = True
+
         return True
 
     def isOnline(self):

eric ide

mercurial