-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Fix 3to4 conversions (thread arguments, OS.window_fullscreen and await) #63299
Conversation
and3rson
commented
Jul 21, 2022
•
edited by akien-mga
Loading
edited by akien-mga
- Fixes --convert-3to4 incorrectly escaping quotes when using signal yields #63291
- Fixes --convert-3to4 messes up thread arguments #63292
- Fixes --convert-3to4 does not escape quotes when migrating params to ProjectSettings.set(...) and breaks scene file #63293
Tagging @qarmin as per Calinou's comments |
99d4285
to
5bd4e34
Compare
FYI: I've also added converters for intersect_ray and intersect_shape since my project uses them extensively :) |
c1f1c22
to
ffa8d0a
Compare
I was referring to the PR description, not the commit message (which I see you've changed). I didn't notice you had the same "Fixes ..." text as the commit message, now I see why you could have interpreted it like this. |
@@ -2803,6 +2807,98 @@ void ProjectConverter3To4::rename_gdscript_functions(String &file_content) { | |||
} | |||
} | |||
|
|||
// -- r.intersect_ray( a, b, c, d, e ) -> var ray_query = ... ray_query.from = from ... r.intersect_ray(ray_query) PhysicsDirectSpaceState2D & PhysicsDirectSpaceState3D |
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.
This will change after #61918 is merged.
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.
Great, didn't know there's a WIP for this. It surely will be much more convenient to have it as a one-liner rather than the current method of creating a separate object. Should we disregard this conversion and wait for #61918?
@@ -1968,11 +1968,14 @@ bool ProjectConverter3To4::test_conversion() { | |||
valid = valid & test_conversion_single_additional("(Disconnect(A,B,C) != OK):", "(Disconnect(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp"); | |||
valid = valid & test_conversion_single_additional("(IsConnected(A,B,C) != OK):", "(IsConnected(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename"); | |||
|
|||
valid = valid & test_conversion_single_additional("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\"display/window/size/fullscreen\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); | |||
valid = valid & test_conversion_single_additional("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename"); |
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.
The problem happens probably only in builtin scripts, so should be fixed only there - otherwise it will broke normal .gd files(not tested yet)
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.
Built-in scripts should be unescaped before conversion, if they aren't already.
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.
My bad, I've totally forgotten that scripts should not be unescaped since they're plaintext. Still, I cannot confirm that built-in scripts are unescaped, i. e. @KoBeWi I can still observe #63291 in the latest master. But I agree that the best solution would be to unescape all built-in scripts before conversion.
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.
What's the difference between rename_gdscript_functions
and check_for_rename_gdscript_functions
btw? Their code seems almost identical (except for the return value).
EDIT: I can see there's a check in project_converter_3_to_4.cpp:1665
which differentiates .gd
and .tscn
files. Should we probably introduce an extra argument to rename_gdscript_functions
such as is_builtin
? This way we could control the behavior of quote escaping inside rename_gdscript_functions
. It would also make sense to call rename_gdscript_functions
inside the .tres
branch several lines below (since resources may also contain built-in scripts).
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.
check_for_rename_gdscript_functions
additionally prints exactly in which line change will happen.
At beginning it was very different than rename_gdscript_functions
, but I unified this one day, so there is a lot of duplicated code, which could be extracted to another function, but when I tried to do it I failed due some strange Regex memory leaks(this shouldn't be too hard to fix)
I think that adding is_builtin
is good solution, but this probably will be only needed by custom renames that use " inside regex e.g.
OS.window_fullscreen = true -> ProjectSettings.set("display/window/size/fullscreen",true)
but not with
sort_custom( a , b ) -> sort_custom(Callable( a , b ))
Oh, I see now. Thank you for taking time to explain! |
@@ -2941,14 +2942,17 @@ void ProjectConverter3To4::rename_gdscript_functions(String &file_content) { | |||
} | |||
} | |||
} | |||
// -- start(a,b,c) -> start(a,Callable(b,c)) Thread | |||
// -- start(a,b) -> start(Callable(a,b)) Thread | |||
// -- start(a,b,c,d) -> start(Callable(a,b).bind(c,d)) Thread |
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.
Threads in 3.x can take only one userdata argument. start(a, b, c, d)
should become start(Callable(a, b).bind(c), d)
, with d
being the Thread priority.
Superseded by #63887. |