Skip to content

Fix crash in Project Settings when an autoload has been freed#120874

Open
meisekimiu wants to merge 1 commit into
godotengine:masterfrom
meisekimiu:fix-crash-on-autoload-settings
Open

Fix crash in Project Settings when an autoload has been freed#120874
meisekimiu wants to merge 1 commit into
godotengine:masterfrom
meisekimiu:fix-crash-on-autoload-settings

Conversation

@meisekimiu

Copy link
Copy Markdown

The EditorAutoloadSettings class does not expect an autoload node to be freed in between its initial instantiation and any calls to update_autoload(). But this actually can happen if the autoload is an editor script and happens to run something like queue_free() shortly after being initialized.

When this happens, opening the project settings panel results in a crash, since the editor is trying to locate data such as the node's script after it has already been deleted.

To fix this, just verify that the node still exists prior to accessing any of the node's data.

What problem(s) does this PR solve?

  • Fixes a crash when opening the Project Settings dialog in the editor after an autoload node has been freed after it was initialized.
    • I've uploaded a reference project that recreates this issue at this URL, though you can easily reproduce this by creating a new autoload and:
      1. Giving it the @tool declaration
      2. Having it immediately run queue_free() on initialization.

Additional information

  • No AI tools were used in the creation of the pull request.
  • I'd be happy to write tests for this, but it doesn't look like there's a precedent for automated tests in editor code? I think?

The `EditorAutoloadSettings` class does not expect an autoload node to
be freed in between its initial instantiation and any calls to
`update_autoload()`. But this actually *can* happen if the autoload is
an editor script and happens to run something like `queue_free()`
shortly after being initialized.

When this happens, opening the project settings panel results in a
crash, since the editor is trying to locate data such as the node's
script after it has already been deleted.

To fix this, just verify that the node still exists prior to accessing
any of the node's data.
@meisekimiu meisekimiu requested a review from a team as a code owner July 2, 2026 22:13
@YeldhamDev YeldhamDev added bug topic:editor crash cherrypick:4.7 Considered for cherry-picking into a future 4.7.x release labels Jul 2, 2026
@YeldhamDev YeldhamDev added this to the 4.8 milestone Jul 2, 2026

@YeldhamDev YeldhamDev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug cherrypick:4.7 Considered for cherry-picking into a future 4.7.x release crash topic:editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants