From 0a14e78a60f227c6415f14be4c6b14f4587e26ab Mon Sep 17 00:00:00 2001 From: Hein-Pieter van Braam Date: Tue, 22 Aug 2017 15:13:31 +0200 Subject: [PATCH] Change order of Null check for ParallaxLayer The change in #10524 subtly changes the behavior of set_motion_scale() and set_motion_offset() if the ParallaxLayer does not have a parent node. Previously it would still set the corresponding property, but after this change the property change would be discarded. I'm not entirely sure if this actually matters as there doesn't appear to be any code that picks up this change if the ParallaxLayer gets re-parented later, but it's better to not change behavior regardless. --- scene/2d/parallax_layer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index 4b62d706489..debdc22b657 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -34,11 +34,11 @@ void ParallaxLayer::set_motion_scale(const Size2 &p_scale) { + motion_scale = p_scale; + if (!get_parent()) return; - motion_scale = p_scale; - ParallaxBackground *pb = get_parent()->cast_to(); if (is_inside_tree() && pb) { Vector2 ofs = pb->get_final_offset(); @@ -54,11 +54,11 @@ Size2 ParallaxLayer::get_motion_scale() const { void ParallaxLayer::set_motion_offset(const Size2 &p_offset) { + motion_offset = p_offset; + if (!get_parent()) return; - motion_offset = p_offset; - ParallaxBackground *pb = get_parent()->cast_to(); if (is_inside_tree() && pb) { Vector2 ofs = pb->get_final_offset();