-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Project Manager: Fix hacky code for project rename #69338
Project Manager: Fix hacky code for project rename #69338
Conversation
6f2f75d
to
500e4b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR council approves
Instantiating a new ProjectSettings is *not* the way to go. ConfigFile works just fine to read/change a single value. Fixes memory leaks as the instantiated ProjectSettings was never freed. Forbid doing this to prevent such problems. Fixes godotengine#25661.
500e4b2
to
f21f75e
Compare
So I checked after someone mentioned it in the PR meeting, and indeed there's a potential risk of losing information by going through the ConfigFile API. Here's the diff after rename for a test project with a few global script classes: --- project.godot.bkp 2022-11-29 15:43:40.739102066 +0100
+++ project.godot 2022-11-29 15:43:47.488103630 +0100
@@ -1,13 +1,4 @@
-; Engine configuration file.
-; It's best edited using the editor UI and not directly,
-; since the parameters that go here are not all obvious.
-;
-; Format:
-; [section] ; section goes between []
-; param=value ; assign values to parameters
-
config_version=5
-
_global_script_classes=[{
"base": "Node",
"class": &"MyClass",
@@ -26,7 +17,7 @@
[application]
-config/name="New Game Project test"
+config/name="New Game Project"
run/main_scene="res://node_2d.tscn"
config/features=PackedStringArray("4.0")
config/icon="res://icon.svg" So it removes comments, and the separation line between Edit: But then when editing the project, Godot restores the comment and separation line so the diff becomes: --- project.godot.bkp 2022-11-29 15:43:40.739102066 +0100
+++ project.godot 2022-11-29 15:46:43.913144506 +0100
@@ -26,7 +26,7 @@
[application]
-config/name="New Game Project test"
+config/name="New Game Project"
run/main_scene="res://node_2d.tscn"
config/features=PackedStringArray("4.0")
config/icon="res://icon.svg" So it's pretty good? I don't know if there are more complex |
I'd go with "Allow ConfigFile to preserve formatting (spacing, comments)", but that'd take some effort. I guess if someone complains, asking them to open the project once is okay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it with a realistic project and it didn't break anything else. I think it's okay as an immediate solution, though it'd be nice to preserve formatting with ConfigFile. Task for another day.
Let's see if this causes problems with the next beta. Thanks for the quick turnaround! |
Cherry-picked for 3.6. |
Cherry-picked for 3.5.2 |
Instantiating a new ProjectSettings is not the way to go. ConfigFile works just fine to read/change a single value.
Fixes memory leaks as the instantiated ProjectSettings was never freed.