Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Fix deletion of image caused selection of the first image #742

Merged
merged 1 commit into from
Apr 28, 2021
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
9 changes: 6 additions & 3 deletions labelImg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,12 +1428,15 @@ def close_file(self, _value=False):
def delete_image(self):
delete_path = self.file_path
if delete_path is not None:
self.open_next_image()
self.cur_img_idx -= 1
del self.m_img_list[self.cur_img_idx]
self.file_list_widget.takeItem(self.cur_img_idx)
Comment on lines +1431 to +1432
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing current image's path from the list of paths and from sidebar widget.


self.cur_img_idx -= 1 # self.open_next_img will increment idx.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removal of a path caused left shift of all of the following paths and the next image's path has the same index as deleted one.
Decrementing because self.open_next_img will increment index later.

self.img_count -= 1
self.open_next_image()

if os.path.exists(delete_path):
os.remove(delete_path)
self.import_dir_images(self.last_open_dir)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer required. Removed not to reload all of the paths and widget items.


def reset_all(self):
self.settings.reset()
Expand Down