6 """ |
6 """ |
7 Module implementing the hex editor main window. |
7 Module implementing the hex editor main window. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
|
11 import contextlib |
11 |
12 |
12 from PyQt5.QtCore import ( |
13 from PyQt5.QtCore import ( |
13 pyqtSignal, pyqtSlot, QFile, QFileInfo, QSize, QCoreApplication, QLocale |
14 pyqtSignal, pyqtSlot, QFile, QFileInfo, QSize, QCoreApplication, QLocale |
14 ) |
15 ) |
15 from PyQt5.QtGui import QKeySequence |
16 from PyQt5.QtGui import QKeySequence |
917 state = self.saveState() |
918 state = self.saveState() |
918 Preferences.setHexEditor("HexEditorState", state) |
919 Preferences.setHexEditor("HexEditorState", state) |
919 |
920 |
920 Preferences.setGeometry("HexEditorGeometry", self.saveGeometry()) |
921 Preferences.setGeometry("HexEditorGeometry", self.saveGeometry()) |
921 |
922 |
922 try: |
923 with contextlib.suppress(ValueError): |
923 if self.__fromEric or len(self.__class__.windows) > 1: |
924 if self.__fromEric or len(self.__class__.windows) > 1: |
924 del self.__class__.windows[ |
925 del self.__class__.windows[ |
925 self.__class__.windows.index(self)] |
926 self.__class__.windows.index(self)] |
926 except ValueError: |
|
927 pass |
|
928 |
927 |
929 if not self.__fromEric: |
928 if not self.__fromEric: |
930 Preferences.syncPreferences() |
929 Preferences.syncPreferences() |
931 |
930 |
932 self.__saveRecent() |
931 self.__saveRecent() |