Skip to content

Commit 7229583

Browse files
committed
Prevent crash when no object was detected on a clip
1 parent 64acae8 commit 7229583

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/windows/video_widget.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,16 @@ def paintEvent(self, event, *args):
341341
# Get properties of clip at current frame
342342
raw_properties_effect = json.loads(self.transforming_effect_object.PropertiesJSON(clip_frame_number))
343343
# Check if the tracked object is visible in this frame
344-
if raw_properties_effect['visible']['value'] == 1:
345-
# Get the selected bounding box values
346-
rotation = raw_properties_effect['rotation']['value']
347-
x1 = raw_properties_effect['x1']['value']
348-
y1 = raw_properties_effect['y1']['value']
349-
x2 = raw_properties_effect['x2']['value']
350-
y2 = raw_properties_effect['y2']['value']
351-
self.drawTransformHandler(painter, sx, sy, source_width, source_height, origin_x, origin_y,
352-
x1, y1, x2, y2, rotation)
344+
if raw_properties_effect.get('visible'):
345+
if raw_properties_effect.get('visible').get('value') == 1:
346+
# Get the selected bounding box values
347+
rotation = raw_properties_effect['rotation']['value']
348+
x1 = raw_properties_effect['x1']['value']
349+
y1 = raw_properties_effect['y1']['value']
350+
x2 = raw_properties_effect['x2']['value']
351+
y2 = raw_properties_effect['y2']['value']
352+
self.drawTransformHandler(painter, sx, sy, source_width, source_height, origin_x, origin_y,
353+
x1, y1, x2, y2, rotation)
353354
else:
354355
self.drawTransformHandler(painter, sx, sy, source_width, source_height, origin_x, origin_y)
355356

@@ -865,11 +866,18 @@ def mouseMoveEvent(self, event):
865866
if self.mouse_dragging and not self.transform_mode:
866867
self.original_clip_data = self.transforming_clip.data
867868

868-
_ = self.getTransformMode(0, 0, 0, event)
869+
869870

870871
if self.transforming_effect_object.info.has_tracked_object:
871872
# Get properties of effect at current frame
872873
raw_properties = json.loads(self.transforming_effect_object.PropertiesJSON(clip_frame_number))
874+
875+
if not raw_properties.get('visible'):
876+
self.mouse_position = event.pos()
877+
self.mutex.unlock()
878+
return
879+
880+
_ = self.getTransformMode(0, 0, 0, event)
873881

874882
# Transform effect object
875883
if self.transform_mode:

0 commit comments

Comments
 (0)