Skip to content

Reuse cached scene resource if already opened in editor when creating autoloads. - #123532

Open
leandro-benedet-garcia wants to merge 1 commit into
godotengine:masterfrom
leandro-benedet-garcia:reuse-cached-scene
Open

leandro-benedet-garcia wants to merge 1 commit into
godotengine:masterfrom
leandro-benedet-garcia:reuse-cached-scene

Conversation

@leandro-benedet-garcia

Copy link
Copy Markdown
Contributor

What problem(s) does this PR solve?

Additional information

With this PR, the editor checks if a cache already exists and if it does, it instantiates the autoload node from it instead of trying to open the file again.

@leandro-benedet-garcia
leandro-benedet-garcia requested a review from a team as a code owner September 15, 2026 22:17
@leandro-benedet-garcia leandro-benedet-garcia changed the title Reuse cached scene resource if already opened in editor. Reuse cached scene resource if already opened in editor when creating autoloads. Sep 15, 2026
@AThousandShips AThousandShips added this to the 4.8 milestone Sep 16, 2026
@KoBeWi

KoBeWi commented Sep 23, 2026

Copy link
Copy Markdown
Member

tbh this code can be replaced simply by Ref<PackedScene> scn = ResourceLoader::load(p_path), which automatically reuses the resource from cache, without all that manual boilerplate. I wonder why it isn't done this way? 🤔

@leandro-benedet-garcia

Copy link
Copy Markdown
Contributor Author

tbh this code can be replaced simply by Ref<PackedScene> scn = ResourceLoader::load(p_path), which automatically reuses the resource from cache, without all that manual boilerplate. I wonder why it isn't done this way? 🤔

I was wondering the same, probably legacy code, I will just change to it and then push if I don't see anything wrong with it.

@AThousandShips

Copy link
Copy Markdown
Member

Not sure how it would be legacy code, the loader cache is very old and the UID system is far younger, so I think there might be some potential reason it wasn't used, so good to look into

@KoBeWi

KoBeWi commented Sep 23, 2026

Copy link
Copy Markdown
Member

If you mean the ensure_path(), it was added when autoloads were changed to UID, on top of the original code.

@AThousandShips

Copy link
Copy Markdown
Member

I mean the UID system as such, but that would also be code that's younger than the cache system

@leandro-benedet-garcia

Copy link
Copy Markdown
Contributor Author

If you mean the ensure_path(), it was added when autoloads were changed to UID, on top of the original code.

I actually meant the autoload system itself and the people that implemented UID to work around a issue in the autoload system, but I am already investigating and trying just to load stuff.

@leandro-benedet-garcia

Copy link
Copy Markdown
Contributor Author

Tested with my own project, tested with the MRP of #69073 and tried to reproduce with the reproduction steps of #123524 All of them are fine with just a load.

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.

[4.8 dev 5] Output window shows errors related to autoloads when opening project settings menu

3 participants