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

SceneTree.new() causes wrong tree to be shown in the remote view #44853

Open
Tracked by #47369
Demindiro opened this issue Jan 1, 2021 · 1 comment
Open
Tracked by #47369

SceneTree.new() causes wrong tree to be shown in the remote view #44853

Demindiro opened this issue Jan 1, 2021 · 1 comment

Comments

@Demindiro
Copy link
Contributor

Godot version:
3.2.3.stable.custom_build.31d0f8ad8

OS/device including version:
Linux pc 4.19.0-12-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux

Issue description:
When creating a new SceneTree with SceneTree.new(), the remote tree view in the editor shows the layout of the new tree instead of the singleton. This happens because of a missing check in the code that assigns the tree in the remote view.

if (ScriptDebugger::get_singleton()) {
if (ScriptDebugger::get_singleton()->is_remote()) {
ScriptDebuggerRemote *remote_debugger = static_cast<ScriptDebuggerRemote *>(ScriptDebugger::get_singleton());
remote_debugger->set_scene_tree(this);
}
ScriptDebugger::get_singleton()->set_multiplayer(multiplayer);
}

Steps to reproduce:

  1. Create a node and add the following script:
extends Node

var tree_a := SceneTree.new()
  1. Run the project.
  2. Check the Remote View. There will only be a root node visible and not the node with the script.

Minimal reproduction project:
multi-scenetree.zip

@Demindiro Demindiro changed the title SceneTree.new() causes wrong tree to be show in the remove view. SceneTree.new() causes wrong tree to be show in the remote view. Jan 1, 2021
@Calinou Calinou changed the title SceneTree.new() causes wrong tree to be show in the remote view. SceneTree.new() causes wrong tree to be show in the remote view Mar 25, 2021
@Calinou Calinou changed the title SceneTree.new() causes wrong tree to be show in the remote view SceneTree.new() causes wrong tree to be shown in the remote view Mar 25, 2021
@ShadyChibinko
Copy link
Contributor

I recently ran into this issue in 3.4.4.stable and it can seriously break the debugging workflow when working with multiple scene trees. More often than not you're creating additional scene trees to run some kind of sub simulation that you've already ironed out prior through the default scene tree. So having the remote inspector display them makes little to no sense. It's also just apparent that this is unintended.

Judging by the code snippet for scene_tree.cpp, I'd assume the fix is as simple as adding a getter for ScriptDebuggerRemote's scene_tree property as defined here:

SceneTree *scene_tree;

Then in the scene_tree.cpp block:
if (ScriptDebugger::get_singleton()) {
if (ScriptDebugger::get_singleton()->is_remote()) {
ScriptDebuggerRemote *remote_debugger = static_cast<ScriptDebuggerRemote *>(ScriptDebugger::get_singleton());
remote_debugger->set_scene_tree(this);
}
ScriptDebugger::get_singleton()->set_multiplayer(multiplayer);

You would gate off the line remote_debugger->set_scene_tree(this); with an if statement checking for a null return value from the aforementioned getter. I don't know exactly how the debugger works behind the scenes, but I'd like to think this is plausible.

It's also worth noting that this solution would likely be 3.x only, as Godot 4 seems to have removed the debugger calls above from scene_tree.cpp's constructor entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants