浏览代码

Check if there is a entry of the image file

Kentaro Wada 6 年之前
父节点
当前提交
d25fd72459
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      labelme/app.py

+ 6 - 3
labelme/app.py

@@ -791,10 +791,13 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
                 flags=flags,
             )
             self.labelFile = lf
-            item = self.fileListWidget.findItems(
+            items = self.fileListWidget.findItems(
                 self.imagePath, Qt.MatchExactly
-            )[0]
-            item.setCheckState(Qt.Checked)
+            )
+            if len(items) > 0:
+                if len(items) == 1:
+                    raise RuntimeError('There are duplicate files.')
+                items[0].setCheckState(Qt.Checked)
             # disable allows next and previous image to proceed
             # self.filename = filename
             return True