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

Fix ThemeDB initialization in tests #81305

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

YuriSizov
Copy link
Contributor

While working on another PR I ran into issues with tests because of how we work with ThemeDB in tests. Basically, each test cases initializes its own ThemeDB instance, which overrides the singleton pointer. This means that interactions with the singleton instance become unreliable. It doesn't cause any visible problems at the moment, but it does with my PR, because I need Control and Window classes to statically interact with the singleton.

So I'm fixing that, and also slightly changing the order of initialization for ThemeDB. Now it's initialized before scene types, so that they can work with it. I also added an explicit way to finalize default resources in ThemeDB, which is needed for test cases which destroy and recreate the theme constantly.

Unfortunately, we have to do it this way, because test cases also create and destroy the RenderingServer instance, which themes need for textures to work. Otherwise I'd just use the singleton.


Also noticed that Viewport and Window tests used the same name for the registered class, causing a warning from ClassDB when running tests. So fixed that as well.

Also fixes class name shadowing in Viewport/Window tests.
register_scene_types();
register_driver_types();

register_scene_singletons();
Copy link
Member

Choose a reason for hiding this comment

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

I trust moving the theme stuff around, but I'm not confident about this. How does this interact with the module/GDExtension scene initialization level? This code is very core and moving stuff around typically breaks stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a method that I've added, it only registers ThemeDB right now and I moved it specifically so the singleton is available for other consumers as early as possible. 🙃

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.

2 participants