Skip to content

Commit ee8a651

Browse files
committed
webview: cache logging, drop local settings ref
1 parent 0309c5d commit ee8a651

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/windows/views/webview.py

+19-16
Original file line numberDiff line numberDiff line change
@@ -2872,7 +2872,7 @@ def callback(self, data, callback_data):
28722872
# Adjust clip duration, start, and end
28732873
new_clip["duration"] = new_clip["reader"]["duration"]
28742874
if file.data["media_type"] == "image":
2875-
new_clip["end"] = self.settings_obj.get("default-image-length") # default to 8 seconds
2875+
new_clip["end"] = settings.get_settings().get("default-image-length") # default to 8 seconds
28762876

28772877
# Overwrite frame rate (incase the user changed it in the File Properties)
28782878
file_properties_fps = float(file.data["fps"]["num"]) / float(file.data["fps"]["den"])
@@ -3100,19 +3100,22 @@ def render_cache_json(self):
31003100
# Get final cache object from timeline
31013101
try:
31023102
cache_object = self.window.timeline_sync.timeline.GetCache()
3103-
if cache_object and cache_object.Count() > 0:
3104-
# Get the JSON from the cache object (i.e. which frames are cached)
3105-
cache_json = self.window.timeline_sync.timeline.GetCache().Json()
3106-
cache_dict = json.loads(cache_json)
3107-
cache_version = cache_dict["version"]
3108-
3109-
if self.cache_renderer_version != cache_version:
3110-
# Cache has changed, re-render it
3111-
self.cache_renderer_version = cache_version
3112-
self.run_js(JS_SCOPE_SELECTOR + ".renderCache({});".format(cache_json))
3113-
finally:
3114-
# ignore any errors inside the cache rendering
3115-
pass
3103+
if not cache_object or cache_object.Count() <= 0:
3104+
return
3105+
# Get the JSON from the cache object (i.e. which frames are cached)
3106+
cache_json = self.window.timeline_sync.timeline.GetCache().Json()
3107+
cache_dict = json.loads(cache_json)
3108+
cache_version = cache_dict["version"]
3109+
3110+
if self.cache_renderer_version == cache_version:
3111+
# Nothing has changed, ignore
3112+
return
3113+
# Cache has changed, re-render it
3114+
self.cache_renderer_version = cache_version
3115+
self.run_js(JS_SCOPE_SELECTOR + ".renderCache({});".format(cache_json))
3116+
except Exception as ex:
3117+
# Log the exception and ignore
3118+
log.warning("Exception processing timeline cache: %s", ex)
31163119

31173120
def __init__(self, window):
31183121
super().__init__()
@@ -3123,8 +3126,7 @@ def __init__(self, window):
31233126
self.setAcceptDrops(True)
31243127
self.last_position_frames = None
31253128

3126-
# Get settings & logger
3127-
self.settings_obj = get_settings()
3129+
# Get logger
31283130
self.log_fn = log.log
31293131

31303132
# Add self as listener to project data updates (used to update the timeline)
@@ -3166,5 +3168,6 @@ def __init__(self, window):
31663168
# Connect shutdown signals
31673169
app.aboutToQuit.connect(self.redraw_audio_timer.stop)
31683170
app.aboutToQuit.connect(self.cache_renderer.stop)
3171+
31693172
# Delay the start of cache rendering
31703173
QTimer.singleShot(1500, self.cache_renderer.start)

0 commit comments

Comments
 (0)