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

Store panels and docks instances in their classes #55066

Merged

Conversation

trollodel
Copy link
Contributor

Based on the work in #47520

This is a cleanup PR that reduces a bit the editor code dependencies to EditorNode.
It moves all the panel and dock instances, currently stored in EditorNode in their classes as a singleton.

This is one approach (IMO the simplest). The other approach is to store the node instances in a dedicated class called EditorSingletons or something like that (closer to what I did in #47520).

@trollodel trollodel requested review from a team as code owners November 17, 2021 20:16
@YeldhamDev YeldhamDev added this to the 4.0 milestone Nov 17, 2021
@trollodel trollodel force-pushed the less_singletons_in_editornode branch from f6e3b8d to 9b92278 Compare November 21, 2021 10:51
@trollodel trollodel requested a review from a team as a code owner November 21, 2021 10:51
Comment on lines +137 to +140
NodeDock::~NodeDock() {
singleton = nullptr;
}
Copy link
Member

Choose a reason for hiding this comment

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

This could be in the header, like in other classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that I checked more carefully, this case is the only one when I need to add a destructor and I add it into the cpp like the other destructors I modified to be consistent. However, I don't mind moving all the destructor I changed to the header.

@KoBeWi
Copy link
Member

KoBeWi commented Jan 11, 2022

Another thing that would be nice to do is unifying the usage of EditorNode singleton. Many plugins will have an editor property. EditorNode is passed in the constructor and saved to that property, but then it's only used half of the time, because the class sometimes still accesses the editor via singleton. I'd remove all these "cached" editors and just always access it using singleton. This way these classes won't need the EditorNode to be passed with constructor for no real reason.

@trollodel
Copy link
Contributor Author

@KoBeWi definitely agree. In fact, this is only the first of some editor related cleanup PRs I want to do, and the EditorNode parameter thing is something I already noted. I waited to do more work because I was unsure if this is desired.

@KoBeWi
Copy link
Member

KoBeWi commented Jan 11, 2022

I waited to do more work because I was unsure if this is desired.

tbh, it's better if you waited a bit longer, so the PR doesn't end like the previous one .-. I'll add a PR meeting label.

@akien-mga
Copy link
Member

We discussed this today in a PR review meeting and agreed with the change.

In fact, this is only the first of some editor related cleanup PRs I want to do, and the EditorNode parameter thing is something I already noted. I waited to do more work because I was unsure if this is desired.

We also intend to cleanup EditorNode at some point, but we decided to postpone that work to after 4.0 is released because we don't have much bandwidth for this in the core team and a lot of pending 4.0 items to finish. So you're welcome to work on this, but be aware that most contributors likely won't have much bandwidth to review it for several months - so you might also prefer to wait for a more opportune time to participate in and/or lead discussions with core contributors and then get the agreed-upon changes done.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Should probably be rebased, then it should be good to merge if it's ready.

@KoBeWi
Copy link
Member

KoBeWi commented Jan 20, 2022

The editor changes I mentioned could be done now, no? It doesn't require EditorNode modifications.

@trollodel trollodel force-pushed the less_singletons_in_editornode branch from 9b92278 to aa1102f Compare January 20, 2022 19:15
@trollodel
Copy link
Contributor Author

We also intend to cleanup EditorNode at some point, but we decided to postpone that work to after 4.0 is released because we don't have much bandwidth for this in the core team and a lot of pending 4.0 items to finish. So you're welcome to work on this, but be aware that most contributors likely won't have much bandwidth to review it for several months - so you might also prefer to wait for a more opportune time to participate in and/or lead discussions with core contributors and then get the agreed-upon changes done.

I didn't want to do massive, risky cleanup PRs for several reasons, including this one. So, I think it's better to start with low risks PRs like this one and the future editor parameter PR (so @KoBeWi is happy 😂).
In any case, feel free to ping me on RC when the topic is raised.

@akien-mga
Copy link
Member

The editor changes I mentioned could be done now, no? It doesn't require EditorNode modifications.

Yeah for sure. As long as there are people available to review low-impact and consensual changes, that's definitely fine.

@akien-mga akien-mga merged commit e6170aa into godotengine:master Jan 20, 2022
@akien-mga
Copy link
Member

Thanks!

@@ -1794,9 +1794,9 @@ void AnimationPlayerEditorPlugin::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
Node3DEditor::get_singleton()->connect("transform_key_request", callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request));
editor->get_inspector()->connect("property_keyed", callable_mp(this, &AnimationPlayerEditorPlugin::_property_keyed));
InspectorDock::get_singleton()->connect("property_keyed", callable_mp(this, &AnimationPlayerEditorPlugin::_property_keyed));
Copy link
Member

@TokageItLab TokageItLab Jan 21, 2022

Choose a reason for hiding this comment

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

It caused bug, since editor->get_inspector() and editor->get_inspector_dock() is different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I probably missed it in the rebase. Thanks for the fix.

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

Successfully merging this pull request may close these issues.

6 participants