Skip to content

Conversation

@channesl
Copy link

@channesl channesl commented Nov 2, 2025

Fixes #112164

Fixes an editor error when a file moved outside the editor is moved back inside the editor. Resource::set_path() is made tolerant of harmless cache collisions so the reassignment doesn’t fail with:

ERROR: Another resource is loaded from path 'res://1.gd' (possible cyclic resource inclusion).

What changed:

  • If the cached entry at p_path is the same object: allow (no-op).
  • If p_take_over == true: evict old entry (unchanged behavior).
  • If the existing entry has no external owners (refcount <= 1): auto-evict as stale.
  • Editor-only (TOOLS_ENABLED): if the new resource has no path yet, allow takeover to reconcile stale editor state.
  • Runtime/export behavior remains strict and unchanged.

External moves can leave a stale ResourceCache entry for the old path. Reassigning the path then collides with that stale entry. The above rules safely evict stale entries (and, in editor builds, resolve transient references) to avoid false errors.

@channesl channesl requested a review from a team as a code owner November 2, 2025 20:41
@channesl channesl changed the title Fix: Resource: Make set_path() resilient to stale cache entries #112164 Fix: Resource: Make set_path() resilient to stale cache entries Nov 2, 2025
@AThousandShips AThousandShips added this to the 4.6 milestone Nov 3, 2025
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.

Restoring externally modified script paths in the editor will result in errors

2 participants