Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 do not rely on autoloads to avoid startup errors #284

Merged
merged 1 commit into from
Jan 6, 2024

Conversation

bitbrain
Copy link
Owner

@bitbrain bitbrain commented Jan 2, 2024

Description

This pull request aims to solve some of the long standing issues with getting Beehave to work on first load.

Addressed issues

Note: can please people test this build of Beehave to verify if this indeed fixes startup errors?

@@ -2,6 +2,8 @@
extends EditorDebuggerPlugin

const DebuggerTab := preload("debugger_tab.gd")
const BeehaveUtils := preload("res://addons/beehave/utils/utils.gd")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This avoids issues at initial load in case the global class cache might not have initialized BeehaveUtils yet.

@@ -20,7 +20,7 @@ func _on_debug_message(message: String, data: Array) -> bool:


func _set_active_tree(tree_id: int) -> void:
var tree: BeehaveTree = _registered_trees.get(tree_id, null)
var tree = _registered_trees.get(tree_id, null)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ideal but removing BeehaveTree from here excludes this class from initial dependency lookups.


# required to avoid lifecycle issues on initial load
# due to loading order problems with autoloads
func _get_global_metrics() -> Node:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autoloads will be added to the scene tree, so we can look them up dynamically. Unfortunately, referencing them directly may not work, as the global class cache may not have loaded them at the time this class here is parsed.

@bitbrain bitbrain merged commit 902d480 into godot-4.x Jan 6, 2024
@bitbrain bitbrain deleted the fix-startup-errors branch January 6, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant