From 632a0c8dd33fe240269e28286c8ad687b2c5ec85 Mon Sep 17 00:00:00 2001 From: Subhang Nanduri Date: Sun, 15 Dec 2019 10:19:58 -0500 Subject: [PATCH] Fix for crashes that occur when using selection tool and line tool --- Scripts/Canvas.gd | 3 ++- Scripts/SelectionRectangle.gd | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 5c09feccc..9ab604335 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -256,7 +256,8 @@ func _process(delta : float) -> void: is_making_line = true elif Input.is_action_just_released("shift"): is_making_line = false - line_2d.queue_free() + if is_instance_valid(line_2d): + line_2d.queue_free() if is_making_line: line_2d.set_point_position(1, mouse_pos) diff --git a/Scripts/SelectionRectangle.gd b/Scripts/SelectionRectangle.gd index 82112ab5b..549fec2d9 100644 --- a/Scripts/SelectionRectangle.gd +++ b/Scripts/SelectionRectangle.gd @@ -63,7 +63,7 @@ func _process(delta : float) -> void: update() # Makes line2d invisible - if weakref(Global.canvas.line_2d).get_ref(): # Checks to see if line_2d object still exists + if is_instance_valid(Global.canvas.line_2d): # Checks to see if line_2d object still exists Global.canvas.line_2d.default_color = Color(0, 0, 0, 0) else: get_parent().get_parent().mouse_default_cursor_shape = Input.CURSOR_ARROW @@ -104,7 +104,7 @@ func _process(delta : float) -> void: Global.canvas.handle_redo("Rectangle Select") #Redo # Makes line2d visible - if weakref(Global.canvas.line_2d).get_ref(): # Checks to see if line_2d object still exists + if is_instance_valid(Global.canvas.line_2d): # Checks to see if line_2d object still exists Global.canvas.line_2d.default_color = Color.darkgray #Handle copy