Skip to content

Commit f844f15

Browse files
authored
Merge pull request #5577 from OpenShot/sentry-fixes-2024-07-08
Fixing more Sentry Errors
2 parents 228b3d5 + fddbdd0 commit f844f15

File tree

7 files changed

+36
-17
lines changed

7 files changed

+36
-17
lines changed

src/windows/add_to_timeline.py

+20-12
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,20 @@ def btnMoveUpClicked(self, checked):
6161
if self.treeFiles.selected:
6262
selected_index = self.treeFiles.selected.row()
6363

64-
# Ignore if empty files
64+
# Ignore if empty files or no selection
6565
if not files or selected_index is None:
6666
return
6767

68-
# New index
69-
new_index = max(selected_index - 1, 0)
70-
log.info(new_index)
68+
# Check if selected_index is within valid range
69+
if 0 <= selected_index < len(files):
70+
# New index
71+
new_index = max(selected_index - 1, 0)
7172

72-
# Remove item and move it
73-
files.insert(new_index, files.pop(selected_index))
73+
# Remove item and move it
74+
files.insert(new_index, files.pop(selected_index))
75+
else:
76+
log.warning(f"Invalid selected_index: {selected_index}, list length: {len(files)}")
77+
return
7478

7579
# Refresh tree
7680
self.treeFiles.refresh_view()
@@ -90,16 +94,20 @@ def btnMoveDownClicked(self, checked):
9094
if self.treeFiles.selected:
9195
selected_index = self.treeFiles.selected.row()
9296

93-
# Ignore if empty files
97+
# Ignore if empty files or no selection
9498
if not files or selected_index is None:
9599
return
96100

97-
# New index
98-
new_index = min(selected_index + 1, len(files) - 1)
99-
log.info(new_index)
101+
# Check if selected_index is within valid range
102+
if 0 <= selected_index < len(files):
103+
# New index
104+
new_index = min(selected_index + 1, len(files) - 1)
100105

101-
# Remove item and move it
102-
files.insert(new_index, files.pop(selected_index))
106+
# Remove item and move it
107+
files.insert(new_index, files.pop(selected_index))
108+
else:
109+
log.warning(f"Invalid selected_index: {selected_index}, list length: {len(files)}")
110+
return
103111

104112
# Refresh tree
105113
self.treeFiles.refresh_view()

src/windows/models/properties_model.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PropertiesModel(updates.UpdateInterface):
7070
def changed(self, action):
7171

7272
# Handle change
73-
if action.key and action.key[0] in ["clips", "effects"] and action.type in ["update", "insert"]:
73+
if len(action.key) >= 1 and action.key[0] in ["clips", "effects"] and action.type in ["update", "insert"]:
7474
log.debug(action.values)
7575
# Update the model data
7676
self.update_model(get_app().window.txtPropertyFilter.text())
@@ -702,7 +702,9 @@ def set_property(self, property, filter, c, item_type, object_id=None):
702702

703703
selected_choice = None
704704
if choices:
705-
selected_choice = [c for c in choices if c["selected"] is True][0]["name"]
705+
selected_choices = [c for c in choices if c.get("selected") is True]
706+
if selected_choices:
707+
selected_choice = selected_choices[0]["name"]
706708

707709
# Hide filtered out properties
708710
if filter and filter.lower() not in _(label).lower():

src/windows/video_widget.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class VideoWidget(QWidget, updates.UpdateInterface):
5252
# This method is invoked by the UpdateManager each time a change happens (i.e UpdateInterface)
5353
def changed(self, action):
5454
# Handle change
55-
if (action.key and action.key[0] in [
55+
if (len(action.key) >= 1 and action.key[0] in [
5656
"display_ratio", "pixel_ratio"
5757
] or action.type in ["load"]):
5858
# Update display ratio (if found)

src/windows/views/properties_tableview.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,8 @@ def contextMenuEvent(self, event):
779779
self.menu = self.build_menu(self.choices, menu)
780780

781781
# Show context menu (if any options present)
782-
if self.menu.children():
782+
# There is always at least 1 QAction in an empty menu though
783+
if len(self.menu.children()) > 1:
783784
self.menu.popup(event.globalPos())
784785

785786
def build_menu(self, data, parent_menu=None):

src/windows/views/timeline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def changed(self, action):
134134
return
135135

136136
# Bail out if change unrelated to webview
137-
if action.key and action.key[0] not in ["clips", "effects", "duration", "layers", "markers"]:
137+
if len(action.key) >= 1 and action.key[0] not in ["clips", "effects", "duration", "layers", "markers"]:
138138
log.debug(f"Skipping unneeded webview update for '{action.key[0]}'")
139139
return
140140

src/windows/views/timeline_backend/qwidget.py

+4
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ def get_html(self):
122122

123123
# This method is invoked by the UpdateManager each time a change happens (i.e UpdateInterface)
124124
def changed(self, action):
125+
# Ignore changes that don't affect this
126+
if action and len(action.key) >= 1 and action.key[0].lower() in ["files", "history", "profile"]:
127+
return
128+
125129
# Clear previous rects
126130
self.clip_rects.clear()
127131
self.clip_rects_selected.clear()

src/windows/views/zoom_slider.py

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class ZoomSlider(QWidget, updates.UpdateInterface):
4646

4747
# This method is invoked by the UpdateManager each time a change happens (i.e UpdateInterface)
4848
def changed(self, action):
49+
# Ignore changes that don't affect this
50+
if action and len(action.key) >= 1 and action.key[0].lower() in ["files", "history", "profile"]:
51+
return
52+
4953
# Clear previous rects
5054
self.clip_rects.clear()
5155
self.clip_rects_selected.clear()

0 commit comments

Comments
 (0)