diff --git a/manuskript/mainWindow.py b/manuskript/mainWindow.py index 4352070..2c5e8e0 100644 --- a/manuskript/mainWindow.py +++ b/manuskript/mainWindow.py @@ -794,6 +794,10 @@ class MainWindow(QMainWindow, Ui_MainWindow): # Remembering the current items (stores outlineItem's ID) settings.openIndexes = self.mainEditor.tabSplitter.openIndexes() + # Call close on the main window to clean children widgets + if self.mainEditor: + self.mainEditor.close() + # Save data from models if settings.saveOnQuit: self.saveDatas() diff --git a/manuskript/ui/editors/fullScreenEditor.py b/manuskript/ui/editors/fullScreenEditor.py index 5c7200d..10b8657 100644 --- a/manuskript/ui/editors/fullScreenEditor.py +++ b/manuskript/ui/editors/fullScreenEditor.py @@ -2,7 +2,7 @@ # --!-- coding: utf8 --!-- import os -from PyQt5.QtCore import Qt, QSize, QPoint, QRect, QEvent, QTime, QTimer +from PyQt5.QtCore import Qt, QSize, QPoint, QRect, QEvent, QTime, QTimer, pyqtSignal from PyQt5.QtGui import QFontMetrics, QColor, QBrush, QPalette, QPainter, QPixmap, QCursor from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import QFrame, QWidget, QPushButton, qApp, QStyle, QComboBox, QLabel, QScrollBar, \ @@ -23,6 +23,8 @@ import logging LOGGER = logging.getLogger(__name__) class fullScreenEditor(QWidget): + exited = pyqtSignal() + def __init__(self, index, parent=None, screenNumber=None): QWidget.__init__(self, parent) self.setAttribute(Qt.WA_DeleteOnClose, True) @@ -178,13 +180,13 @@ class fullScreenEditor(QWidget): # self.showMaximized() # self.show() - def __del__(self): - LOGGER.debug("Leaving fullScreenEditor via Destructor event.") - self.showNormal() - self.close() - def leaveFullscreen(self): + self.__exit__("Leaving fullScreenEditor via leaveFullScreen.") + + def __exit__(self, message): + LOGGER.debug(message) self.showNormal() + self.exited.emit() self.close() def setLocked(self, val): @@ -288,9 +290,7 @@ class fullScreenEditor(QWidget): def keyPressEvent(self, event): if event.key() in [Qt.Key_Escape, Qt.Key_F11] and \ not self._locked: - LOGGER.debug("Leaving fullScreenEditor via keyPressEvent.") - self.showNormal() - self.close() + self.__exit__("Leaving fullScreenEditor via keyPressEvent.") elif (event.modifiers() & Qt.AltModifier) and \ event.key() in [Qt.Key_PageUp, Qt.Key_PageDown, Qt.Key_Left, Qt.Key_Right]: if event.key() in [Qt.Key_PageUp, Qt.Key_Left]: diff --git a/manuskript/ui/editors/mainEditor.py b/manuskript/ui/editors/mainEditor.py index 8cc6453..7ee4300 100644 --- a/manuskript/ui/editors/mainEditor.py +++ b/manuskript/ui/editors/mainEditor.py @@ -67,6 +67,7 @@ class mainEditor(QWidget, Ui_mainEditor): QWidget.__init__(self, parent) self.setupUi(self) self._updating = False + self._fullScreen = None self.mw = mainWindow() @@ -154,6 +155,10 @@ class mainEditor(QWidget, Ui_mainEditor): for ts in reversed(self.allTabSplitters()): ts.closeSplit() + def close(self): + if self._fullScreen is not None: + self._fullScreen.leaveFullscreen() + def allTabs(self, tabWidget=None): """Returns all the tabs from the given tabWidget. If tabWidget is None, from the current tabWidget.""" if tabWidget == None: @@ -386,6 +391,11 @@ class mainEditor(QWidget, Ui_mainEditor): self._fullScreen = fullScreenEditor( self.currentEditor().currentIndex, screenNumber=currentScreenNumber) + # Clean the variable when closing fullscreen prevent errors + self._fullScreen.exited.connect(self.clearFullScreen) + + def clearFullScreen(self): + self._fullScreen = None ############################################################################### # DICT AND STUFF LIKE THAT