瀏覽代碼

Fixing potential bug

LATENTIX\ht 5 年之前
父節點
當前提交
dc4967b330
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      labelme/widgets/canvas.py

+ 5 - 4
labelme/widgets/canvas.py

@@ -360,10 +360,11 @@ class Canvas(QtWidgets.QWidget):
             self.overrideCursor(CURSOR_GRAB)
         if self.movingShape:
             # Only save if changes have actually been made
-            currentShapeIndex = self.shapes.index(self.hShape)
-            if not self.shapesBackups[-1][currentShapeIndex].points == self.shapes[currentShapeIndex].points:
-                self.storeShapes()
-                self.shapeMoved.emit()
+            if self.hShape is not None:
+                currentShapeIndex = self.shapes.index(self.hShape)
+                if not self.shapesBackups[-1][currentShapeIndex].points == self.shapes[currentShapeIndex].points:
+                    self.storeShapes()
+                    self.shapeMoved.emit()
 
     def endMove(self, copy):
         assert self.selectedShapes and self.selectedShapesCopy