diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index bdee066d579..e88d26aba78 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -257,7 +257,9 @@ void ScrollContainer::_notification(int p_what) { }; if (p_what == NOTIFICATION_READY) { - get_viewport()->connect("gui_focus_changed", this, "_gui_focus_changed"); + Viewport *viewport = get_viewport(); + ERR_FAIL_COND(!viewport); + viewport->connect("gui_focus_changed", this, "_gui_focus_changed"); } if (p_what == NOTIFICATION_SORT_CHILDREN) {