1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Fixed crash when creating a new image and a layer had opacity less than 100%

Caused in CreateNewImage.gd, Global.current_layer = 0 should be under Global.canvas gets set to a new canvas, and after its _ready() method gets executed. The crash occurred when a layer above 0 had transparency less than 100, and a new image was created. _on_OpacitySlider_value_changed() in AnimationTimeline.gd was executed on the old canvas right before it was destroyed, while Global.layers had been cleared.

Also removed _on_OpacitySlider_value_changed() from Main.gd, it served no purpose there.
This commit is contained in:
OverloadedOrama 2020-04-11 05:36:51 +03:00
parent 2404798749
commit 3f1c81ac13
4 changed files with 10 additions and 15 deletions

View file

@ -307,6 +307,7 @@ func _on_MergeDownLayer_pressed() -> void:
Global.undo_redo.add_do_method(Global, "redo", Global.canvases) Global.undo_redo.add_do_method(Global, "redo", Global.canvases)
Global.undo_redo.commit_action() Global.undo_redo.commit_action()
func _on_OpacitySlider_value_changed(value) -> void: func _on_OpacitySlider_value_changed(value) -> void:
Global.canvas.layers[Global.current_layer][2] = value / 100 Global.canvas.layers[Global.current_layer][2] = value / 100
Global.layer_opacity_slider.value = value Global.layer_opacity_slider.value = value

View file

@ -74,12 +74,12 @@ func _on_CreateNewImage_confirmed() -> void:
# Store [Layer name (0), Layer visibility boolean (1), Layer lock boolean (2), Frame container (3), # Store [Layer name (0), Layer visibility boolean (1), Layer lock boolean (2), Frame container (3),
# will new frames be linked boolean (4), Array of linked frames (5)] # will new frames be linked boolean (4), Array of linked frames (5)]
Global.layers.append([tr("Layer") + " 0", true, false, HBoxContainer.new(), false, []]) Global.layers.append([tr("Layer") + " 0", true, false, HBoxContainer.new(), false, []])
Global.current_layer = 0
Global.canvas = load("res://Prefabs/Canvas.tscn").instance() Global.canvas = load("res://Prefabs/Canvas.tscn").instance()
Global.canvas.size = Vector2(width, height).floor() Global.canvas.size = Vector2(width, height).floor()
Global.canvases.append(Global.canvas) Global.canvases.append(Global.canvas)
Global.canvas_parent.add_child(Global.canvas) Global.canvas_parent.add_child(Global.canvas)
Global.current_layer = 0
Global.canvases = Global.canvases # To trigger Global.canvases_changed() Global.canvases = Global.canvases # To trigger Global.canvases_changed()
Global.current_frame = 0 Global.current_frame = 0
Global.layers = Global.layers # To trigger Global.layers_changed() Global.layers = Global.layers # To trigger Global.layers_changed()

View file

@ -628,12 +628,6 @@ func _on_RightHorizontalMirroring_toggled(button_pressed) -> void:
func _on_RightVerticalMirroring_toggled(button_pressed) -> void: func _on_RightVerticalMirroring_toggled(button_pressed) -> void:
Global.right_vertical_mirror = button_pressed Global.right_vertical_mirror = button_pressed
func _on_OpacitySlider_value_changed(value) -> void:
Global.canvas.layers[Global.current_layer][4] = value / 100
Global.layer_opacity_slider.value = value
Global.layer_opacity_spinbox.value = value
Global.canvas.update()
func show_quit_dialog() -> void: func show_quit_dialog() -> void:
if !$QuitDialog.visible: if !$QuitDialog.visible:
if Global.saved: if Global.saved: