godot icon indicating copy to clipboard operation
godot copied to clipboard

Use forward-declarations in big editor classes

Open trollodel opened this issue 2 years ago • 3 comments

Follow up of #60684

Reduce the number of includes in some editor classes that are included a lot.

Add forward declarations in touched headers. Remove some unused includes.

trollodel avatar Nov 23 '22 18:11 trollodel

I noticed you added some new includes in some .h files (editor node, canvas item editor, script text editor etc.). I assume you plan to handle them in follow-up PR(s)?

Not really. They need non-trivial refactoring (and in some cases you can't e.g., with subclasses), which I don't plan to do. What I'll do in follow-up PRs is to further forward declare stuff.

trollodel avatar Nov 27 '22 17:11 trollodel

But includes are only needed when you inherit the class or define a method inside header. I checked these files and it doesn't seem to be the case there.

KoBeWi avatar Nov 27 '22 17:11 KoBeWi

I checked these files and it doesn't seem to be the case there.

EditorData doesn't agree with you 😀

But includes are only needed when you inherit the class or define a method inside header

Another thing that can't be included are enums defined in classes. This is why, e.g., EditorNode needs editor_plugin.h. This is what I gather from a quick search. If there is some ~~obscure~~ C++ syntax for it, then I'm happy to use that and remove the includes.

trollodel avatar Nov 27 '22 18:11 trollodel

Thanks!

akien-mga avatar Nov 29 '22 09:11 akien-mga