godot: Errors after setting custom theme in project settings

Godot version

v3.4.stable.official [206ba70f4]

System information

Windows 10

Issue description

I’m using a custom theme in my project. Instead of having to remember to manually set the custom theme override for each Control node in various scenes to be able to get an accurate preview, I’ve set the custom theme in the Project Settings.

Godot 3 4 Bug Report - Project Settings Custom Theme

When I press F5 (or F6) to test the project/scene I get a bunch of errors related to loading the theme and custom images as the window launches.

E 0:00:00.724   _load_data: Condition "img.is_null() || img->empty()" is true. Returned: ERR_FILE_CORRUPT
  <C++ Source>  scene/resources/texture.cpp:566 @ _load_data()
E 0:00:00.731   _load: Failed loading resource: res://.import/GuiChecked.svg-40071e1e72cdcbe9d0e9ea53c8ee9f94.stex. Make sure resources have been imported by opening the project in the editor at least once.
  <C++ Error>   Condition "found" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:270 @ _load()
E 0:00:00.738   _load: Failed loading resource: res://assets/ui/GuiChecked.svg. Make sure resources have been imported by opening the project in the editor at least once.
  <C++ Error>   Condition "found" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:270 @ _load()
E 0:00:00.745   poll: res://theme.tres:4 - Parse Error: [ext_resource] referenced nonexistent resource at: res://assets/ui/GuiChecked.svg
  <C++ Source>  scene/resources/resource_format_text.cpp:412 @ poll()
E 0:00:00.749   load: Failed to load resource 'res://theme.tres'.
  <C++ Error>   Condition "err != OK" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:206 @ load()
E 0:00:00.755   _load: Failed loading resource: res://theme.tres. Make sure resources have been imported by opening the project in the editor at least once.
  <C++ Error>   Condition "found" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:270 @ _load()
E 0:00:00.759   register_scene_types: Error loading custom theme 'res://theme.tres'
  <C++ Source>  scene/register_scene_types.cpp:795 @ register_scene_types()

If I unset the custom theme from Project Settings and just set my top-most Control node’s Theme override to use the custom theme, these errors go away. Furthermore, when I have the custom theme configured as a project setting and launch a scene which doesn’t have any Control nodes (i.e., no custom theme set or referenced in the scene), I still get these errors. This leads me to believe that my custom theme is okay, and all the related files are okay, but that the problem is somehow related to how the custom theme interacts with the Project Settings.

Steps to reproduce

  1. Open minimal reproduction project and press F5.
  2. Check Errors tab of Debugger to see the errors.

Minimal reproduction project

CustomThemeBugReport.zip

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (5 by maintainers)

Commits related to this issue

Most upvoted comments

AureaFUNSoft’s comment got me to double check, because I thought the theme was working despite these errors. And I found something interesting.

If I close the project, delete the .import folder, then open the project again in Godot 3.3.4, the custom theme setting in the Project Settings works without problems. If I then close the project and open it again in Godot 3.4, the custom theme settings in the Project Settings also works without problems (no errors).

But if I then delete the .import folder again and open the project in Godot 3.4, I get the errors and the custom theme does not work. The issue seems to be related to how Godot 3.4 imports the theme. If Godot 3.3.4 imports the theme, then Godot 3.4 can read it just fine. But if Godot 3.4 imports the theme, I get errors.

So the current workaround is to delete the .import folder, import the project in 3.3.4, then relaunch the project using Godot 3.4.

I just tested that hypothesis by removing the SVG images from the custom theme and replacing one of them with a PNG. I get the same 7 errors in the same order, but of course this time they refer to the PNG where they used to refer to the SVG.