--- a/eric7/Snapshot/SnapWidget.py Mon Jun 20 13:25:14 2022 +0200 +++ b/eric7/Snapshot/SnapWidget.py Mon Jun 20 19:47:39 2022 +0200 @@ -17,8 +17,7 @@ import contextlib from PyQt6.QtCore import ( - pyqtSlot, Qt, QFile, QTimer, QPoint, QMimeData, QLocale, QStandardPaths, - QIODevice + pyqtSlot, Qt, QTimer, QPoint, QMimeData, QLocale, QStandardPaths ) from PyQt6.QtGui import QImageWriter, QPixmap, QDrag, QKeySequence, QShortcut from PyQt6.QtWidgets import QWidget, QApplication @@ -240,22 +239,11 @@ if not res: return False - file = QFile(fileName) - if not file.open(QIODevice.OpenModeFlag.WriteOnly): - EricMessageBox.warning( - self, self.tr("Save Snapshot"), - self.tr("Cannot write file '{0}:\n{1}.") - .format(fileName, file.errorString())) - return False - - ok = self.__snapshot.save(file) - file.close() - + ok = self.__snapshot.save(fileName) if not ok: EricMessageBox.warning( self, self.tr("Save Snapshot"), - self.tr("Cannot write file '{0}:\n{1}.") - .format(fileName, file.errorString())) + self.tr("Cannot write file '{0}'.").format(fileName)) return ok