Browse Source

fix for undo/redo history persisting when loading threads and making new threads

Jonathan Higgins 2 months ago
parent
commit
52ff4b066b
2 changed files with 5 additions and 0 deletions
  1. 2 0
      scenes/main/scripts/control.gd
  2. 3 0
      scenes/main/scripts/save_load.gd

+ 2 - 0
scenes/main/scripts/control.gd

@@ -140,6 +140,8 @@ func new_patch():
 	
 	
 	await get_tree().process_frame  # Wait for nodes to actually be removed
 	await get_tree().process_frame  # Wait for nodes to actually be removed
 	
 	
+	undo_redo.clear_history()
+	
 	graph_edit.scroll_offset = Vector2(0, 0)
 	graph_edit.scroll_offset = Vector2(0, 0)
 	
 	
 		#Generate input and output nodes
 		#Generate input and output nodes

+ 3 - 0
scenes/main/scripts/save_load.gd

@@ -138,6 +138,7 @@ func load_graph_edit(path: String):
 			node.queue_free()
 			node.queue_free()
 
 
 	await get_tree().process_frame  # Ensure nodes are freed before adding new ones
 	await get_tree().process_frame  # Ensure nodes are freed before adding new ones
+	
 
 
 	#set fft size and window overlap if available
 	#set fft size and window overlap if available
 	if graph_data.has("fftsize"):
 	if graph_data.has("fftsize"):
@@ -244,6 +245,8 @@ func load_graph_edit(path: String):
 	print("Graph loaded.")
 	print("Graph loaded.")
 	get_window().title = "SoundThread - " + path.get_file().trim_suffix(".thd")
 	get_window().title = "SoundThread - " + path.get_file().trim_suffix(".thd")
 	
 	
+	#clear all undo history from old threads and building this one
+	control_script.undo_redo.clear_history()
 	control_script.changesmade = false
 	control_script.changesmade = false