fix setting dirty multiple times when initializing from deck

This commit is contained in:
Lera Elvoé 2023-12-13 19:59:25 +03:00
parent d29adb8166
commit 4f40e91726
No known key found for this signature in database

View file

@ -32,10 +32,13 @@ signal group_enter_requested(group_id: String)
var dirty: bool = false:
set(v):
dirty = v
dirty_state_changed.emit()
if change_dirty:
dirty = v
dirty_state_changed.emit()
var is_group: bool = false
var change_dirty: bool = true
signal dirty_state_changed
## Sets up the [member search_popup_panel] with an instance of [member ADD_NODE_SCENE]
@ -114,18 +117,20 @@ func _on_scroll_offset_changed(offset: Vector2) -> void:
## Setups all the data from the set [member deck] in this [DeckRendererGraphEdit]
func initialize_from_deck() -> void:
change_dirty = false
for i in get_children():
i.queue_free()
scroll_offset = deck.get_meta("offset", Vector2())
is_group = deck.is_group
dirty = false
for node_id in deck.nodes:
var node_renderer: DeckNodeRendererGraphNode = NODE_SCENE.instantiate()
node_renderer.node = deck.nodes[node_id]
add_child(node_renderer)
node_renderer.position_offset = node_renderer.node.position_as_vector2()
change_dirty = true
dirty = false
refresh_connections()