Browse Source

[2.1] Add null check to ParallaxLayer get_parent() calls

This fixes #10515
Hein-Pieter van Braam 8 years ago
parent
commit
f33e8d7793
1 changed files with 6 additions and 0 deletions
  1. 6 0
      scene/2d/parallax_layer.cpp

+ 6 - 0
scene/2d/parallax_layer.cpp

@@ -32,6 +32,9 @@
 
 void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
 
+	if (!get_parent())
+		return;
+
 	motion_scale = p_scale;
 
 	ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
@@ -49,6 +52,9 @@ Size2 ParallaxLayer::get_motion_scale() const {
 
 void ParallaxLayer::set_motion_offset(const Size2 &p_offset) {
 
+	if (!get_parent())
+		return;
+
 	motion_offset = p_offset;
 
 	ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();