From 943e20a0de3b02579864b9ef2cf0b5914dcfd236 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Mon, 6 Apr 2020 18:35:54 +0300 Subject: [PATCH] Fixed crash on Linux with layer containers When the user clicked on a layer container to change its name and then clicked away, the program crashed. This was because the name of the layer was changed (`Global.layers[i][0] = new_name`), and Global.layers_changed() was being called, which removed all of the layer container UI and re-created it. This is unneeded to happen when only the layer name changes, so I added a boolean to skip the execution of the method. Oddly enough, the crash was not happening on Windows (at least on my end) and it was working as expected. Godot's output terminal was not showing any error messages, either. --- Scripts/Global.gd | 4 ++++ Scripts/LayerContainer.gd | 1 + 2 files changed, 5 insertions(+) diff --git a/Scripts/Global.gd b/Scripts/Global.gd index 046d81531..19674c266 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -16,6 +16,7 @@ var saved := true # Checks if the user has saved # Canvas related stuff var canvases := [] setget canvases_changed var layers := [] setget layers_changed +var layers_changed_skip := false var current_frame := 0 setget frame_changed var current_layer := 0 setget layer_changed # warning-ignore:unused_class_variable @@ -500,6 +501,9 @@ func canvases_changed(value : Array) -> void: func layers_changed(value : Array) -> void: layers = value + if layers_changed_skip: + layers_changed_skip = false + return for container in layers_container.get_children(): container.queue_free() diff --git a/Scripts/LayerContainer.gd b/Scripts/LayerContainer.gd index fb6a80518..dc8d93b8d 100644 --- a/Scripts/LayerContainer.gd +++ b/Scripts/LayerContainer.gd @@ -55,6 +55,7 @@ func save_layer_name(new_name : String) -> void: line_edit.visible = false line_edit.editable = false label.text = new_name + Global.layers_changed_skip = true Global.layers[i][0] = new_name func _on_VisibilityButton_pressed() -> void: