Godot Engine – Multi-platform 2D and 3D game engine
Fix navigation bug when going to help.
jinyangcruise85ae9b4c05de
diff --git a/editor/doc/editor_help.cpp b/editor/doc/editor_help.cppindex 4c28b1bcbb2..dc33aa58b0b 100644--- a/editor/doc/editor_help.cpp+++ b/editor/doc/editor_help.cpp@@ -2453,13 +2453,13 @@ void EditorHelp::_class_desc_scroll_to_paragraph(int p_line, bool p_save_historyDictionary state = get_state();// Row 0 is not a state worth saving as a previous state to history.if (int(state["row"]) > 0) {- emit_signal(SNAME("_request_save_new_history"), state);+ call_on_all_layout_pending_finished(callable_mp(this, &EditorHelp::_emit_request_save_new_history).bind(state));}}class_desc->scroll_to_paragraph(p_line);// Save history after scrolling.if (p_save_history) {- emit_signal(SNAME("_request_save_new_history"), get_state());+ call_on_all_layout_pending_finished(callable_mp(this, &EditorHelp::_emit_request_save_new_history).bind(get_state()));if (ScriptEditorNavigationMarker::get_singleton()->is_locating()) {ScriptEditorNavigationMarker::get_singleton()->locate_end();}@@ -2470,6 +2470,10 @@ bool EditorHelp::_need_save_new_history() const {return !ScriptEditorNavigationMarker::get_singleton()->is_initializing() && ScriptEditorNavigationMarker::get_singleton()->is_locating();}+void EditorHelp::_emit_request_save_new_history(const Dictionary &p_state) {+ emit_signal(SNAME("_request_save_new_history"), p_state);+}+static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, const Control *p_owner_node, const String &p_class) {bool is_native = false;{@@ -3427,7 +3431,7 @@ void EditorHelp::update_doc() {void EditorHelp::trigger_history_save_on_navigate() {if (_need_save_new_history()) {- emit_signal(SNAME("_request_save_new_history"), get_state());+ call_on_all_layout_pending_finished(callable_mp(this, &EditorHelp::_emit_request_save_new_history).bind(get_state()));if (ScriptEditorNavigationMarker::get_singleton()->is_locating()) {ScriptEditorNavigationMarker::get_singleton()->locate_end();}diff --git a/editor/doc/editor_help.h b/editor/doc/editor_help.hindex ff567cbafed..2634566622f 100644--- a/editor/doc/editor_help.h+++ b/editor/doc/editor_help.h@@ -151,6 +151,7 @@ class EditorHelp : public VBoxContainer {void _help_callback(const String &p_topic);void _class_desc_scroll_to_paragraph(int p_line, bool p_save_history);bool _need_save_new_history() const;+ void _emit_request_save_new_history(const Dictionary &p_state);void _add_text(const String &p_bbcode);bool scroll_locked = false;diff --git a/scene/gui/control.cpp b/scene/gui/control.cppindex e9c67b950dd..4802ad9d3d6 100644--- a/scene/gui/control.cpp+++ b/scene/gui/control.cpp@@ -2164,7 +2164,7 @@ void Control::remove_child_notify(Node *p_child) {bool Control::is_layout_pending() const {ERR_MAIN_THREAD_GUARD_V(false);- return data.layout_pending;+ return data.layout_pending || !is_inside_tree() || !is_visible_in_tree();}bool Control::is_layout_pending_in_tree() const {@@ -2202,6 +2202,18 @@ Control *Control::get_layout_pending_control_in_tree() const {}void Control::call_on_all_layout_pending_finished(const Callable &p_callable) {+ if (!is_inside_tree()) {+ Callable recheck(memnew(LayoutRecheckCallable(get_instance_id(), p_callable)));+ connect(SceneStringName(tree_entered), recheck, CONNECT_ONE_SHOT);+ return;+ }++ if (!is_visible_in_tree()) {+ Callable recheck(memnew(LayoutRecheckCallable(get_instance_id(), p_callable)));+ connect(SceneStringName(visibility_changed), recheck, CONNECT_ONE_SHOT);+ return;+ }+Control *pending_control = get_layout_pending_control_in_tree();if (pending_control != nullptr) {Callable recheck(memnew(LayoutRecheckCallable(get_instance_id(), p_callable)));