Skip to content

Commit

Permalink
fix: Prevent crash on startup by deferring loop_thru_labels activation
Browse files Browse the repository at this point in the history
  • Loading branch information
CVHub520 committed Oct 2, 2024
1 parent 148aba0 commit 41799b5
Show file tree
Hide file tree
Showing 7 changed files with 18,929 additions and 18,894 deletions.
36,384 changes: 18,196 additions & 18,188 deletions anylabeling/resources/resources.py

Large diffs are not rendered by default.

704 changes: 357 additions & 347 deletions anylabeling/resources/translations/en_US.ts

Large diffs are not rendered by default.

Binary file modified anylabeling/resources/translations/zh_CN.qm
Binary file not shown.
704 changes: 357 additions & 347 deletions anylabeling/resources/translations/zh_CN.ts

Large diffs are not rendered by default.

29 changes: 17 additions & 12 deletions anylabeling/views/labeling/label_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def __init__( # noqa: C901
shortcut=shortcuts["loop_thru_labels"],
icon="loop",
tip=self.tr("Loop through labels"),
enabled=True
enabled=False
)

zoom = QtWidgets.QWidgetAction(self)
Expand Down Expand Up @@ -1353,13 +1353,13 @@ def __init__( # noqa: C901
create_line_strip_mode,
edit_mode,
brightness_contrast,
loop_thru_labels,
),
on_shapes_present=(save_as,),
hide_selected_polygons=hide_selected_polygons,
show_hidden_polygons=show_hidden_polygons,
group_selected_shapes=group_selected_shapes,
ungroup_selected_shapes=ungroup_selected_shapes,
loop_thru_labels=loop_thru_labels,
)

self.canvas.vertex_selected.connect(
Expand Down Expand Up @@ -1494,10 +1494,12 @@ def __init__( # noqa: C901
None,
fill_drawing,
None,
loop_thru_labels,
None,
zoom_in,
zoom_out,
zoom_org,
None,
keep_prev_scale,
keep_prev_brightness,
keep_prev_contrast,
Expand All @@ -1517,8 +1519,6 @@ def __init__( # noqa: C901
show_hidden_polygons,
group_selected_shapes,
ungroup_selected_shapes,
None,
loop_thru_labels,
),
)

Expand Down Expand Up @@ -1551,16 +1551,16 @@ def __init__( # noqa: C901
self.actions.create_line_mode,
self.actions.create_point_mode,
self.actions.create_line_strip_mode,
None,
edit_mode,
delete,
undo,
loop_thru_labels,
None,
zoom,
fit_width,
toggle_auto_labeling_widget,
run_all_images,
None,
loop_thru_labels,
)

layout = QHBoxLayout()
Expand Down Expand Up @@ -2536,6 +2536,13 @@ def information(self):
info_box.exec_()

def loop_thru_labels(self):
self.label_loop_count += 1
if len(self.label_list) == 0 or self.label_loop_count >= len(self.label_list):
# If we go through all the things go back to 100%
self.label_loop_count = -1
self.set_zoom(int(100*self.scale_fit_window()))
return

width = self.central_widget().width() - 2.0
height = self.central_widget().height() - 2.0

Expand All @@ -2544,12 +2551,6 @@ def loop_thru_labels(self):

zoom_scale = 4

self.label_loop_count += 1
if self.label_loop_count >= len(self.label_list):
#If we go through all the things go back to 100%
self.label_loop_count = -1
self.set_zoom(int(100*self.scale_fit_window()))
return
item = self.label_list[self.label_loop_count]
xs = []
ys = []
Expand Down Expand Up @@ -3601,6 +3602,10 @@ def load_file(self, filename=None): # noqa: C901
if self.image_data:
self.image_path = filename
self.label_file = None

# Reset the label loop count
self.label_loop_count = -1

image = QtGui.QImage.fromData(self.image_data)

if image.isNull():
Expand Down
1 change: 1 addition & 0 deletions docs/en/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ The current default keyboard shortcuts in X-AnyLabeling are as follows. Users ca
| Ctrl + f | Fit to window |
| Ctrl + Shift + f | Fit to width |
| Ctrl + Shift + m | Merge selected rectangle shapes |
| Ctrl + Shift + n | Loop through shapes |
| Ctrl + z | Undo last action |
| Delete | Delete selected shape |
| Esc | Deselect object |
Expand Down
1 change: 1 addition & 0 deletions docs/zh_cn/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ python3 tools/label_converter.py --task mots --mode custom_to_gt --src_path /pat
| Ctrl + f | 适应窗口 |
| Ctrl + Shift + f | 适应宽度 |
| Ctrl + Shift + m | 合并选定的对象 |
| Ctrl + Shift + n | 遍历标签对象 |
| Ctrl + z | 撤销上一操作 |
| Delete | 删除选中对象 |
| Esc | 取消选择的对象 |
Expand Down

0 comments on commit 41799b5

Please sign in to comment.