From bac875be66073d3f36adc3f03c391e724986888e Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Thu, 10 Mar 2016 21:00:01 +0200 Subject: [PATCH] Fix a crash when running a game with Controls with a tools build Regression from #3997 TOOLS_ENABLED is defined, even when running from editor, but EDITOR_DEF SEGFAULTs --- scene/gui/control.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 0364f732758..d7befd6e11d 100644 --- a/scene/gui/control.cpp +++ b/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(); + 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