godotengine / godotengine/godot

ResourceFormatSaver - Custom File formats fails to create when code is edited anywhere in the project.

Open
#112,645 4 comments 0 reactions 0 assignees View on GitHub
needs testing topic:editor topic:plugin
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Tested on version 4.5.1

### System information

Macbook pro M3 pro

### Issue description

Im working on creating a custom format using ResourceFormatSaver and ResourceFormatLoader, those are being register in the EditorPlugin. The idea is to create a file with an extension .custom, the file creation works until code changes anywhere in the project. Even if the code is not related to the Plugin code, any code really. And happens on internal editor or external editor.

When code is changed and a file is attemp to be created, this throws the next error code: ERR_FILE_UNRECOGNIZED = 15.

My guess is that maybe when the code change and is saved, and the code is reloaded the ResourceFormat is not registered anymore and thats why files are not recognized after that.

My work around was to re-register the ResourceFormatSaver and Loader when signal tree_changed is triggered, but it is an issue after all and doesn't seems documented anywhere.

### Steps to reproduce

Step 1:
Go to Project/tools/Create Custom File <---- to create a new file with .custom extension just name it icon.custom, the plugin handles the extension if is not added

Step 2:
Open the file main.gd and add a comment or modify the code, that will break the ResourceSaver

Step 3:
Create again a new file and this time the error is ERR_FILE_UNRECOGNIZED = 15

Step 4:
Reestart the project to test again

As an aditional step change the variable should_refresh inside of newext.gd that is the EditorPlugin script, to do the re-registration that I mentioned before. Then test the same steps before to see that now, at least does the intented behaviour, but is it ideal, or was something wrong on my end?

### Minimal reproduction project (MRP)

[bug-example.zip](https://github.com/user-attachments/files/23480045/bug-example.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached bug-example.zip and reproduce the failure using Project/tools/Create Custom File, then edit main.gd and retry creation. Read the ResourceFormatSaver and ResourceFormatLoader registration in newext.gd, including the should_refresh workaround. Done means custom files can be created after a project code reload without manual re-registration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.