diff --git a/src/classes/waveform.py b/src/classes/waveform.py index 8248e35e5d..004f6f1139 100644 --- a/src/classes/waveform.py +++ b/src/classes/waveform.py @@ -41,7 +41,7 @@ SAMPLES_PER_SECOND = 20 -def get_audio_data(files: dict): +def get_audio_data(files: dict, transaction_id=None): """Get a Clip object form libopenshot, and grab audio data For for the given files and clips, start threads to gather audio data. @@ -52,11 +52,11 @@ def get_audio_data(files: dict): clip_list = files[file_id] log.info("Clip loaded, start thread") - t = threading.Thread(target=get_waveform_thread, args=[file_id, clip_list], daemon=True) + t = threading.Thread(target=get_waveform_thread, args=[file_id, clip_list, transaction_id], daemon=True) t.start() -def get_waveform_thread(file_id, clip_list): +def get_waveform_thread(file_id, clip_list, transaction_id): """ For the given file ID and clip IDs, update audio data. @@ -117,7 +117,10 @@ def getAudioData(file, channel=-1, tid=None): return # Transaction id to group all deletes together - tid = str(uuid.uuid4()) + if transaction_id: + tid = transaction_id + else: + tid = str(uuid.uuid4()) # If the file doesn't have audio data, generate it. # A pending audio_data process will have audio_data == [-999] diff --git a/src/windows/views/webview.py b/src/windows/views/webview.py index df4f54605c..368aa65bf1 100644 --- a/src/windows/views/webview.py +++ b/src/windows/views/webview.py @@ -1046,7 +1046,7 @@ def Transform_Triggered(self, action, clip_ids): # Clear transform self.window.TransformSignal.emit("") - def Show_Waveform_Triggered(self, clip_ids): + def Show_Waveform_Triggered(self, clip_ids, transaction_id=None): """Show a waveform for all selected clips""" # Group clip IDs under each File ID @@ -1062,7 +1062,7 @@ def Show_Waveform_Triggered(self, clip_ids): files[file_id].append(clip.data.get("id")) # Get audio data for all "selected" files/clips - get_audio_data(files) + get_audio_data(files, transaction_id=transaction_id) def Hide_Waveform_Triggered(self, clip_ids): """Hide the waveform for the selected clip""" @@ -1117,6 +1117,10 @@ def Split_Audio_Triggered(self, action, clip_ids): # Get translation method _ = get_app()._tr + # Group transactions + tid = self.get_uuid() + get_app().updates.transaction_id = tid + # Loop through each selected clip for clip_id in clip_ids: @@ -1179,7 +1183,7 @@ def Split_Audio_Triggered(self, action, clip_ids): # Generate waveform for new clip log.info("Generate waveform for split audio track clip id: %s" % clip.id) - self.Show_Waveform_Triggered([clip.id]) + self.Show_Waveform_Triggered([clip.id], transaction_id=tid) if action == MENU_SPLIT_AUDIO_MULTIPLE: # Get # of channels on clip @@ -1232,7 +1236,7 @@ def Split_Audio_Triggered(self, action, clip_ids): # Generate waveform for new clip log.info("Generate waveform for split audio track clip ids: %s" % str(separate_clip_ids)) - self.Show_Waveform_Triggered(separate_clip_ids) + self.Show_Waveform_Triggered(separate_clip_ids, transaction_id=tid) for clip_id in clip_ids: @@ -1248,9 +1252,12 @@ def Split_Audio_Triggered(self, action, clip_ids): clip.data["has_audio"] = {"Points": [p_object]} # Save filter on original clip - self.update_clip_data(clip.data, only_basic_props=False, ignore_reader=True) + self.update_clip_data(clip.data, only_basic_props=False, ignore_reader=True, transaction_id=tid) clip.save() + # Clear transaction + get_app().updates.transaction_id = None + def Layout_Triggered(self, action, clip_ids): """Callback for the layout context menus""" log.debug(action)