-
-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Properly show detach script button when script is added via inspector #108122
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
Conversation
You can't just connect |
Makes sense. Do you have a suggestion for where to check for queued updates? My first guess would under the |
The usual pattern is
|
5b07c6e
to
a00caa9
Compare
I've implemented the requested changes. One thing I realized is that clicking the script button in the scene tree dock to remove the script will call |
Now that we have a queue method, it can be used more. So yes. |
Replaced all I chose to divide the PR's work into three commit since they were separate atomic changes that someone might want to cherry-pick/revert/etc independently, but I can squash them together if that is preferrable. |
Could you squash the commits? See our PR workflow documentation for details: https://docs.godotengine.org/en/latest/contributing/workflow/pr_workflow.html#the-interactive-rebase |
No problem, I'm aware of the workflow. Just to be sure, I'll reiterate my last comment, but will squash as asked:
|
Fixes godotengine#107059. The SceneTreeDock was not tracking script changes in selected nodes in any capacity as far as I could assess. To do that, my solution essentially connects the "script_changed" signal from selected nodes to "SceneTreeDock::_update_script_button()" whenever the selection changes. It actually queues the update to make sure it happens only once no matter how many nodes are selected. However, only connecting that signal would leave previously selected nodes with a signal connection that should no longer exist. To properly disconnect previously selected nodes, we have to store the list of currently selected nodes so we can disconnect them when the selection changes. The commit also includes some improvements to the SceneTreeDock class: 1. Remove unnecessary initialization in SceneTreeDock This field is already initialized in the line that declares it. As such, initializing it on the constructor as well as is redundant. 2. Queue script button updates in scene tree dock Since we now have the option to defer the script button update and make sure it only runs once per frame, it's always best to use the queued version of the update from a performance perspective. I'm not entirely sure if there could be any unexpected side effects but it is a minor self-contained UI update, so it's likely a relatively safe change. The replacement includes the bindings since it is a requirement for the other replacements in the class to work (UndoRedo needs their method names registered in the class DB). It should be OK to remove the old non-queued bindings too even though they are accessible in the public API because it is a "unofficial" method starting with an underscore.
Thanks! |
When closing the scene tab, the pointers in |
I'll work on a fix. Is there an issue open yet? |
Thank you, opened an issue: #108783 |
PR to fix the crash: #108785 |
Fixes #107059.
The SceneTreeDock was not tracking script changes in selected nodes in any capacity as far as I could assess. To do
that, my solution essentially connects the "script_changed" signal from selected nodes to
SceneTreeDock::_update_script_button()
whenever the selection changes. It actually queues the update to make sure ithappens only once no matter how many nodes are selected.
However, only connecting that signal would leave previously selected nodes with a signal connection that should no
longer exist. To properly disconnect previously selected nodes, we have to store the list of currently selected nodes so
we can disconnect them when the selection changes.
The PR also replaces all uses of
SceneTreeDock::_update_script_button()
with the queued alternative, besides other minor minor improvements requested in the review. See commit message for more details.