diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-06-13 10:40:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-13 10:40:37 +0200 |
commit | 100305413434c39f851140cdaf17672481844b5d (patch) | |
tree | f1bab492eab1326eeb3991e11850da7dcca7a953 /scene | |
parent | 558f13e4f7d4f5abeeaa127b4fa11982f6a8e030 (diff) | |
parent | 80927b7a81c4f2ea962ffd81a962437d05063403 (diff) |
Merge pull request #49553 from timothyqiu/viewport-outside-tree
Fix Viewport crashes when not in tree
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/viewport.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 17c0023b09..5369792194 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2547,6 +2547,8 @@ void Viewport::_gui_remove_control(Control *p_control) { } Window *Viewport::get_base_window() const { + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); + Viewport *v = const_cast<Viewport *>(this); Window *w = Object::cast_to<Window>(v); while (!w) { @@ -3336,6 +3338,7 @@ bool Viewport::is_input_handled() const { return local_input_handled; } else { const Viewport *vp = this; + ERR_FAIL_COND_V(!is_inside_tree(), false); while (true) { if (Object::cast_to<Window>(vp)) { break; |