Skip to content

Commit 0979288

Browse files
committed
Protect setWindowTitle from being called by a different thread (preview_thread - if sample_rate is updated). Protect preview_thread::update() method from triggering with 'sample_rate' update.
1 parent 91b19e5 commit 0979288

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

src/windows/main_window.py

+6-15
Original file line numberDiff line numberDiff line change
@@ -2545,26 +2545,17 @@ def SetWindowTitle(self, profile=None):
25452545

25462546
# Is this a saved project?
25472547
if not app.project.current_filepath:
2548-
# Not saved yet
2549-
self.setWindowTitle(
2550-
"%s %s [%s] - %s" % (
2551-
save_indicator,
2552-
_("Untitled Project"),
2553-
profile,
2554-
"OpenShot Video Editor",
2555-
))
2548+
# Not saved yet (use singleShot since this method can be invoked by our preview thread)
2549+
QTimer.singleShot(0, functools.partial(self.setWindowTitle,
2550+
"%s %s [%s] - %s" % (save_indicator, _("Untitled Project"), profile, "OpenShot Video Editor")))
25562551
else:
25572552
# Yes, project is saved
25582553
# Get just the filename
25592554
filename = os.path.basename(app.project.current_filepath)
25602555
filename = os.path.splitext(filename)[0]
2561-
self.setWindowTitle(
2562-
"%s %s [%s] - %s" % (
2563-
save_indicator,
2564-
filename,
2565-
profile,
2566-
"OpenShot Video Editor",
2567-
))
2556+
# Use singleShot since this method can be invoked by our preview thread
2557+
QTimer.singleShot(0, functools.partial(self.setWindowTitle,
2558+
"%s %s [%s] - %s" % (save_indicator, filename, profile, "OpenShot Video Editor")))
25682559

25692560
# Update undo and redo buttons enabled/disabled to available changes
25702561
def updateStatusChanged(self, undo_status, redo_status):

src/windows/preview_thread.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def changed(self, action):
4545
""" This method is invoked by the UpdateManager each time a change happens (i.e UpdateInterface) """
4646

4747
# Ignore changes that don't affect libopenshot
48-
if len(action.key) >= 1 and action.key[0].lower() in ["files", "history", "markers", "layers", "scale", "profile"]:
48+
if len(action.key) >= 1 and action.key[0].lower() in ["files", "history", "markers", "layers",
49+
"scale", "profile", "sample_rate"]:
4950
return
5051

5152
try:

0 commit comments

Comments
 (0)