--- a/eric6/IconEditor/IconEditorGrid.py Sun Apr 11 16:53:48 2021 +0200 +++ b/eric6/IconEditor/IconEditorGrid.py Sun Apr 11 18:45:10 2021 +0200 @@ -549,10 +549,12 @@ @param evt reference to the mouse event object (QMouseEvent) """ if evt.button() == Qt.MouseButton.LeftButton: - if self.__curTool in [self.Pencil, self.Rubber]: - if self.__currentUndoCmd: - self.__currentUndoCmd.setAfterImage(self.__image) - self.__currentUndoCmd = None + if ( + self.__curTool in [self.Pencil, self.Rubber] and + self.__currentUndoCmd + ): + self.__currentUndoCmd.setAfterImage(self.__image) + self.__currentUndoCmd = None if self.__curTool not in [self.Pencil, self.Rubber, self.Fill, self.ColorPicker, @@ -857,16 +859,18 @@ img.fill(qRgba(0, 0, 0, 0)) for i in range(0, self.__selRect.width()): for j in range(0, self.__selRect.height()): - if self.__image.rect().contains(self.__selRect.x() + i, - self.__selRect.y() + j): - if self.__isMarked( - self.__selRect.x() + i, self.__selRect.y() + j): - img.setPixel(i, j, self.__image.pixel( - self.__selRect.x() + i, self.__selRect.y() + j)) - if cut: - self.__image.setPixel(self.__selRect.x() + i, - self.__selRect.y() + j, - qRgba(0, 0, 0, 0)) + if ( + self.__image.rect().contains( + self.__selRect.x() + i, self.__selRect.y() + j) and + self.__isMarked(self.__selRect.x() + i, + self.__selRect.y() + j) + ): + img.setPixel(i, j, self.__image.pixel( + self.__selRect.x() + i, self.__selRect.y() + j)) + if cut: + self.__image.setPixel(self.__selRect.x() + i, + self.__selRect.y() + j, + qRgba(0, 0, 0, 0)) if cut: self.__undoStack.push(cmd)