@tool crashes when i try to change a resource, error with @export it works before update to 4.6

Godot Version

Godot 4.6

Question

the editor crashes when I add the data in the array via inspector, two days ago before passing between 4.5 to 4.6 it work fine, the editor simply freeze and doesnt send any error message, i have two codes of @tool resources, the error is only in line Backlog = aux

@tool
extends Resource
class_name LoopTimeKeyClass

@export var is_persistent : bool

@export var Backlog : Array[Resource] = []

@export var Forwardlog : Array[Resource] = []

func AddToBackLog(value : Resource):
	var aux = Backlog.duplicate()
	aux.append(value)

#error line
#################################################
#################################################
	Backlog = aux
#################################################
#################################################
	print("entro")
	
#the rest are the same function with little changes

-------------second code--------------------------------
@tool
class_name EventTimeLoopResource
extends Resource

@export var id : String  

@export var description : String  
@export var node_container_name : String  

@export var ActivatorsKeys : Array[LoopTimeKeyClass]= [] : 
	set(value):
		Change_activators_key(value,ActivatorsKeys,"BackLog")
		ActivatorsKeys = value
		notify_property_list_changed()


@export var OutputsKeys : Array[LoopTimeKeyClass]= [] : 
	set(value):
		Change_activators_key(value,ActivatorsKeys,"ForwardLog")
		ActivatorsKeys = value
		notify_property_list_changed()


@export var is_active : bool = false


func Change_activators_key(new_key :Array[LoopTimeKeyClass] ,previous_key :Array[LoopTimeKeyClass],ListToChange : String):
	
	var Added_keys:Array[LoopTimeKeyClass]  = new_key.filter(func(item): return not previous_key.has(item))
	UpdateKey(Added_keys,"AddTo"+ListToChange)
	
	var deleted_keys :Array[LoopTimeKeyClass]  = previous_key.filter(func(item): return not new_key.has(item))
	UpdateKey(deleted_keys,"EraseFrom"+ListToChange)


func UpdateKey(keys_to_modify : Array[LoopTimeKeyClass], name_function_to_use : String):
	if(keys_to_modify.size() > 0):
		print("las keys para son" +str(keys_to_modify))
		for i in keys_to_modify:
			if i and i.has_method(name_function_to_use):
				i.call(name_function_to_use,self)
			else:
				push_warning("El recurso no está cargado completamente o falta el método: " + str(i)+"de la funcion"+name_function_to_use)
	

The way duplicate() works was changed in 4.6, and there have been a number of bugs related to that. This may be a bug they did not catch. I would recommend reporting it in the Godot Project.

1 Like

testing i find, the error occurs only if backlog and forward is @exportexport, but i dont know if exist any form to make it work