Browse Source

Merge pull request #4007 from bojidar-bg/PR-fix-controls

Fix a crash when running a game with Controls with a tools build
Rémi Verschelde 9 years ago
parent
commit
c6e57bf514
1 changed files with 6 additions and 1 deletions
  1. 6 1
      scene/gui/control.cpp

+ 6 - 1
scene/gui/control.cpp

@@ -1175,7 +1175,12 @@ void Control::set_anchor(Margin p_margin,AnchorType p_anchor, bool p_keep_margin
 
 void Control::_set_anchor(Margin p_margin,AnchorType p_anchor) {
 	#ifdef TOOLS_ENABLED
-	set_anchor(p_margin, p_anchor, EDITOR_DEF("2d_editor/keep_margins_when_changing_anchors", false));
+	SceneTree *st=OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
+	if (st && st->is_editor_hint()) {
+		set_anchor(p_margin, p_anchor, EDITOR_DEF("2d_editor/keep_margins_when_changing_anchors", false));
+	} else {
+		set_anchor(p_margin, p_anchor);
+	}
 	#else
 	set_anchor(p_margin, p_anchor);
 	#endif