Skip to content

Commit 97d84df

Browse files
committed
Experimental launch.py changes, to remove our main() function and add some additional protection for render_cache_json() timer during shutdown.
1 parent 4c01c6c commit 97d84df

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/launch.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from classes import info
5353

5454

55-
def main():
55+
if __name__ == "__main__":
5656
""""Initialize settings (not implemented) and create main window/application."""
5757

5858
parser = argparse.ArgumentParser(description = 'OpenShot version ' + info.SETUP['version'])
@@ -141,7 +141,3 @@ def main():
141141

142142
# Run and return result
143143
sys.exit(app.run())
144-
145-
146-
if __name__ == "__main__":
147-
main()

src/windows/views/webview.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -3145,20 +3145,21 @@ def render_cache_json(self):
31453145

31463146
# Get final cache object from timeline
31473147
try:
3148-
cache_object = self.window.timeline_sync.timeline.GetCache()
3149-
if not cache_object or cache_object.Count() <= 0:
3150-
return
3151-
# Get the JSON from the cache object (i.e. which frames are cached)
3152-
cache_json = self.window.timeline_sync.timeline.GetCache().Json()
3153-
cache_dict = json.loads(cache_json)
3154-
cache_version = cache_dict["version"]
3155-
3156-
if self.cache_renderer_version == cache_version:
3157-
# Nothing has changed, ignore
3158-
return
3159-
# Cache has changed, re-render it
3160-
self.cache_renderer_version = cache_version
3161-
self.run_js(JS_SCOPE_SELECTOR + ".renderCache({});".format(cache_json))
3148+
if self.window.timeline_sync and self.window.timeline_sync.timeline:
3149+
cache_object = self.window.timeline_sync.timeline.GetCache()
3150+
if not cache_object or cache_object.Count() <= 0:
3151+
return
3152+
# Get the JSON from the cache object (i.e. which frames are cached)
3153+
cache_json = self.window.timeline_sync.timeline.GetCache().Json()
3154+
cache_dict = json.loads(cache_json)
3155+
cache_version = cache_dict["version"]
3156+
3157+
if self.cache_renderer_version == cache_version:
3158+
# Nothing has changed, ignore
3159+
return
3160+
# Cache has changed, re-render it
3161+
self.cache_renderer_version = cache_version
3162+
self.run_js(JS_SCOPE_SELECTOR + ".renderCache({});".format(cache_json))
31623163
except Exception as ex:
31633164
# Log the exception and ignore
31643165
log.warning("Exception processing timeline cache: %s", ex)

0 commit comments

Comments
 (0)