Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing dependencies after renaming a placeholder scene #37818

Open
timothyqiu opened this issue Apr 12, 2020 · 10 comments · May be fixed by #75103
Open

Missing dependencies after renaming a placeholder scene #37818

timothyqiu opened this issue Apr 12, 2020 · 10 comments · May be fixed by #75103

Comments

@timothyqiu
Copy link
Member

timothyqiu commented Apr 12, 2020

Godot version:

  • v3.2.1.stable.official
  • v4.0.dev.custom_build.9dc19f761

OS/device including version: macOS Catalina 10.15.4

Issue description:

Renaming / drag & dropping a scene to another folder may cause missing dependencies if the scene is marked "Load as Placeholder".

  • If the main scene is still open, it can not be saved until I remove and readd the placeholder node.
  • If the main scene is not open, I won't be able to open the scene again. The only way to fix it seems to be manually changing the instance_placeholder="res://XXX.tscn" field in the tscn file.

Steps to reproduce:

  1. Create a new 2D scene, save as 'Sprite.tscn'
  2. Create a new 2D scene, save as 'Main.tscn'
  3. Instance Sprite in Main
  4. Right click the Sprite node, and check 'Load as Placeholder'
  5. Two cases:
    1. Close the Main scene
      • Rename 'Sprite.tscn' to 'Other.tscn' in FileSystem dock
      • Try to open 'Main.tscn'
      • Alert: Missing 'Main.tscn' or its dependencies.
    2. Keep the Main scene open
      • Rename 'Sprite.tscn' to 'Other.tscn' in FileSystem dock
      • Try to save 'Main.tscn'
      • Alert: Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied.

Minimal reproduction project: N/A

@realkotob
Copy link
Contributor

realkotob commented May 11, 2020

Still happens on latest beta 3.2.2, but it can be fixed manually by editing the tscn file.

[node name="MyNode" parent="." instance_placeholder="res://path/to/scene.tscn"]

This probably happens because the dependencies for placeholders are linked in a different way to regular instances, they are not linked at the top of the file, they are in-line at the node location.

The easiest way to fix this would be to go through "all" the nodes in the tscn file and check if they are a placeholder, which would not involve changing the way placeholders are saved.

Another way would be to list the placeholder dependencies at the top of the file as well so they can be found more easily.

@Flavelius
Copy link
Contributor

Same underlying issue: #44720

@moohamedenios
Copy link

still not working

@API-Beast
Copy link

Can confirm still an issue in 3.5 RC 5.

If you mark an node as placeholder using the context menu, save the scene, close it and then move the referenced node using the FileSystem tab the reference is not updated and thus the scene file can't be opened in the editor anymore and the tscn file needs to be manually fixed using a text editor.

@Jaku-San
Copy link

Happened to me Godot 4 Beta 6. I had an instanciated scene in a currently unsaved scene, i renamed the instantiated scene in the filesystem and when i went to save the current scene i had this error. Not sure if it's an issue and Godot should update my instantiated scene or not, i wasn't able to "Open in editor" as it didn't find it obviously. I removed the instantiated scene and added it back., solved.

@eh-jogos
Copy link

eh-jogos commented Mar 7, 2023

Have this issue in Godot 4.0 stable as well. It would be nice to be able to fix the scene inside godot somehow instead of search/replace in some text editor.

I get that the whole purpose of "instance as placeholder" is that the scene being referenced is not an "external resource" anymore and won't be loaded by default, but maybe there could be a check in the editor specific for placeholders, and at least give a better error message instead of a generic "Scene file 'scene_path.tscn' appears to be invalid/corrupt".

Just reporting the line in which the tscn found the invalid/corrupt error would already help, but if we could have a message more targeted to placholder scene paths being outdated or even a window to "fix placeholder dependencies" similar to the one that fixes the normal external resources would be great!

@API-Beast
Copy link

If the point of "Instance as Placeholder" is that it is not referenced as a external resource then maybe the solution would be to simply not fail loading the scene when the placeholder references a non-existent resource. Then there would have to be a way to change the path.

Though this might open a can of worms of having to deal with both valid and invalid placeholders and it might just be simpler to fix references the same way external resources are already handled.

@Flavelius
Copy link
Contributor

Flavelius commented Mar 8, 2023

My attempt to address this issue can be found here: https://github.com/Flavelius/godot/tree/fix_placeholders
It only handles the 'rename' feature in editor though. It doesn't fix the issue of opening an already invalid scene (as that's a bit more involved and overlaps in code with another pullrequest i'm trying to get recognized)
Edit: this is now also handled.

It changes the way renaming dependencies currently accesses skipped file content (binary blob -> text) so it might be a little slower to execute on many files. But every other way i see also just involves parsing the whole file in a similar way as placeholder paths are not ext_resources, so cannot be short-circuit-ed out.

If that's enough and works for typical usecases though, i can create a pullrequest for it.

@kryptot7
Copy link

Just ran into this issue on Godot 4.2.1-stable.

@CG-Tespy
Copy link

CG-Tespy commented Apr 8, 2024

I've run into this issue with 4.2.1-stable as well. The difference being that it happened out of nowhere when opening a project that was just fine earlier that day

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

Successfully merging a pull request may close this issue.