Эх сурвалжийг харах

Refactor Canvas.undoLastPoint

Kentaro Wada 7 жил өмнө
parent
commit
643aea5866
1 өөрчлөгдсөн 9 нэмэгдсэн , 8 устгасан
  1. 9 8
      labelme/canvas.py

+ 9 - 8
labelme/canvas.py

@@ -540,14 +540,15 @@ class Canvas(QtWidgets.QWidget):
         self.drawingPolygon.emit(True)
 
     def undoLastPoint(self):
-        if self.current and not self.current.isClosed():
-            self.current.popPoint()
-            if len(self.current) > 0:
-                self.line[0] = self.current[-1]
-            else:
-                self.current = None
-                self.drawingPolygon.emit(False)
-            self.repaint()
+        if not self.current or self.current.isClosed():
+            return
+        self.current.popPoint()
+        if len(self.current) > 0:
+            self.line[0] = self.current[-1]
+        else:
+            self.current = None
+            self.drawingPolygon.emit(False)
+        self.repaint()
 
     def loadPixmap(self, pixmap):
         self.pixmap = pixmap