Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions PPOCRLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,19 @@ def rotateImg(self, filename, k, _value):
ext = os.path.splitext(filename)[1]
cv2.imencode(ext, pix)[1].tofile(filename)
self.canvas.update()

# Remove confirmation status after rotation
img_idx = self.getImglabelidx(filename)
if img_idx in self.fileStatedict:
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code should handle the case where getImglabelidx(filename) returns None or an invalid value. If img_idx is None, the in check will still pass but pop() could fail or behave unexpectedly.

Suggested change
if img_idx in self.fileStatedict:
if img_idx is not None and img_idx in self.fileStatedict:

Copilot uses AI. Check for mistakes.
self.fileStatedict.pop(img_idx)

# Remove the "done" icon from the file list
if filename in self.mImgList:
currIndex = self.mImgList.index(filename)
item = self.fileListWidget.item(currIndex)
if item:
item.setIcon(QIcon())
Comment on lines +1409 to +1413
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using list.index() after checking membership with in results in two linear searches through the list. Store the index from the first search or use a try-catch block with index() directly to avoid the redundant search.

Suggested change
if filename in self.mImgList:
currIndex = self.mImgList.index(filename)
item = self.fileListWidget.item(currIndex)
if item:
item.setIcon(QIcon())
try:
currIndex = self.mImgList.index(filename)
item = self.fileListWidget.item(currIndex)
if item:
item.setIcon(QIcon())
except ValueError:
pass

Copilot uses AI. Check for mistakes.

self.loadFile(filename)

def rotateImgWarn(self):
Expand Down