From 80927b7a81c4f2ea962ffd81a962437d05063403 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sun, 13 Jun 2021 11:36:32 +0800 Subject: Fix Viewport crashes when not in tree --- scene/main/viewport.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scene') 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(this); Window *w = Object::cast_to(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(vp)) { break; -- cgit v1.2.3