src/eric7/MicroPython/MicroPythonWidget.py

branch
eric7
changeset 10512
b7292f2691f9
parent 10482
72d9b5ea39b4
child 10518
1682f3203ae5
--- a/src/eric7/MicroPython/MicroPythonWidget.py	Thu Jan 18 13:17:38 2024 +0100
+++ b/src/eric7/MicroPython/MicroPythonWidget.py	Fri Jan 19 09:36:51 2024 +0100
@@ -1477,24 +1477,26 @@
         Private slot to cross compile the current editor to a .mpy file.
         """
         aw = ericApp().getObject("ViewManager").activeWindow()
-        if not aw.checkDirty():
-            # editor still has unsaved changes, abort...
-            return
-        if not aw.isPyFile():
-            # no Python file
-            EricMessageBox.critical(
-                self,
-                self.tr("Compile Current Editor"),
-                self.tr(
-                    """The current editor does not contain a Python"""
-                    """ file. Aborting..."""
-                ),
+        if aw:
+            if not aw.checkDirty():
+                # editor still has unsaved changes, abort...
+                return
+
+            if not aw.isPyFile():
+                # no Python file
+                EricMessageBox.critical(
+                    self,
+                    self.tr("Compile Current Editor"),
+                    self.tr(
+                        """The current editor does not contain a Python"""
+                        """ file. Aborting..."""
+                    ),
+                )
+                return
+
+            self.__crossCompile(
+                pythonFile=aw.getFileName(), title=self.tr("Compile Current Editor")
             )
-            return
-
-        self.__crossCompile(
-            pythonFile=aw.getFileName(), title=self.tr("Compile Current Editor")
-        )
 
     @pyqtSlot()
     def __showDocumentation(self):

eric ide

mercurial