Skip to content

Commit c1f8330

Browse files
committed
Improve speed of mass timeline updates (moving hundreds of clips), by disabling ZoomSlider, VideoCaching, certain log outputs, and adding a Wait cursor. This is easily a 10X improvement for many large timelines.
1 parent 24645ee commit c1f8330

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/windows/main_window.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2630,7 +2630,6 @@ def SetWindowTitle(self, profile=None):
26302630

26312631
# Update undo and redo buttons enabled/disabled to available changes
26322632
def updateStatusChanged(self, undo_status, redo_status):
2633-
log.info('updateStatusChanged')
26342633
self.actionUndo.setEnabled(undo_status)
26352634
self.actionRedo.setEnabled(redo_status)
26362635
self.actionClearHistory.setEnabled(undo_status | redo_status)

src/windows/views/timeline.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,20 @@ def update_clip_data(self, clip_json, only_basic_props=True,
195195
log.warning('Failed to parse clip JSON data', exc_info=1)
196196
return
197197

198+
if not ignore_refresh:
199+
# Refresh ZoomSlider and Enable video caching
200+
get_app().restoreOverrideCursor()
201+
self.window.sliderZoomWidget.ignore_updates = False
202+
openshot.Settings.Instance().ENABLE_PLAYBACK_CACHING = True
203+
else:
204+
# Ignore certain updates for now (no ZoomSlider drawing, or video caching)
205+
if not self.window.sliderZoomWidget.ignore_updates:
206+
get_app().setOverrideCursor(QCursor(Qt.WaitCursor))
207+
self.window.sliderZoomWidget.ignore_updates = True
208+
openshot.Settings.Instance().ENABLE_PLAYBACK_CACHING = False
209+
# Keep UI from freezing during mass timeline updates
210+
get_app().processEvents()
211+
198212
# Search for matching clip in project data (if any)
199213
existing_clip = Clip.get(id=clip_data.get("id"))
200214
if not existing_clip:

src/windows/views/zoom_slider.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ 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+
if self.ignore_updates:
50+
return
51+
4952
# Ignore changes that don't affect this
5053
if action and len(action.key) >= 1 and action.key[0].lower() in ["files", "history", "profile"]:
5154
return
@@ -515,6 +518,7 @@ def __init__(self, *args):
515518
self.current_frame = 0
516519
self.is_auto_center = True
517520
self.min_distance = 0.02
521+
self.ignore_updates = False
518522

519523
# Load icon (using display DPI)
520524
self.cursors = {}
@@ -537,7 +541,6 @@ def __init__(self, *args):
537541

538542
# Connect zoom functionality
539543
self.win.TimelineScrolled.connect(self.update_scrollbars)
540-
541544
self.win.TimelineResize.connect(self.delayed_resize_callback)
542545

543546
# Connect Selection signals

0 commit comments

Comments
 (0)