-
-
Notifications
You must be signed in to change notification settings - Fork 22.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 some arguments being passed as references in virtual functions #92175
base: master
Are you sure you want to change the base?
Conversation
ee46c66
to
0a68e66
Compare
I'd appreciate if someone using C# could test if the unchanged interface allows returning values from these methods through the parameters, will confirm if the GDScript even works as is later today, if either doesn't this makes this change unavoidable IMO |
As per godotengine/godot-cpp#1471 I believe this may be related to a wider issue - some of the reference parameters that shouldn't be In my limited testing with an I dropped some breakpoints in I tried to do more testing over the last week with my godot build to create a fixed version, but I'm not familiar enough with the GDVIRTUAL system to make the necessary modifications. I've not tested any interface beyond
@AThousandShips I also tested it in an |
Thank you so much for your testing! Then at least the GDScript side works, can't test with C# at the moment but might be able to later |
0a68e66
to
e4d27a6
Compare
e4d27a6
to
ddced1a
Compare
ddced1a
to
8821bd0
Compare
9bf5d1a
to
4fa0a75
Compare
4fa0a75
to
c2c5e1c
Compare
c2c5e1c
to
a6bc6de
Compare
a6bc6de
to
a216584
Compare
a216584
to
0327bbd
Compare
0327bbd
to
dd724f7
Compare
This comment was marked as resolved.
This comment was marked as resolved.
95e1407
to
d8ce880
Compare
d8ce880
to
8cfd75e
Compare
ff4f5c5
to
0261c8e
Compare
0261c8e
to
41849df
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.
Thanks! The code looks good to me. I'm very happy to see the virtual method compat system getting some use :-)
But I think the docs could give more information about the returned Dictionary
s and their expected keys - more specific notes about that below
<param index="0" name="resource" type="Resource" /> | ||
<param index="1" name="size" type="Vector2i" /> | ||
<param index="2" name="metadata" type="Dictionary" /> | ||
<description> | ||
Generate a preview from a given resource with the specified size. This must always be implemented. | ||
Returning [code]null[/code] is an OK way to fail and let another generator take care. |
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 can't return null
because it now returns a Dictionary
. This applies to _generate_from_path
also
<return type="Texture2D" /> | ||
<return type="Dictionary" /> |
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.
Looking at the code, I can see that the Texture2D
is supposed to go in the Dictionary
under "result"
- but this should be explained in the docs. This applies to _generate_from_path
also
<description> | ||
Generate a preview from a given resource with the specified size. This must always be implemented. | ||
Returning [code]null[/code] is an OK way to fail and let another generator take care. | ||
Care must be taken because this function is always called from a thread (not the main thread). | ||
[param metadata] dictionary can be modified to store file-specific metadata that can be used in [method EditorResourceTooltipPlugin._make_tooltip_for_path] (like image size, sample length etc.). |
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 should probably still say the same things but refer to the "metadata"
key in the Dictionary
instead
Absolutely, the documentation updates was (as noted in the task list) waiting for approval of the actual specific implementations, so any and all suggestions are welcome |
These can't be used safely in extensions, replaced with
Dictionary
returnsA few cases could do with this improvement, like
EditorSceneFormatImporter::_import_scene
but focused on cases that had arguments that were unusable, at least generallyThis is patterned on the way
ScriptLanguageExtension::_validate
and similar are written, alternatively this could passGDExtensionPtr
but that would make these methods inaccessible from scripting, which considering some of them have documentation showing how to use them in GDScript and C# feels like the wrong way to go. Those cases do work (as far as I know, haven't tested the unchanged code) in at least GDScript (don't know if the passed references are useable in C#) but they use constant references in at least godot-cpp, which couldn't be changed without making broad changes there without handling other cases as there's no way to distinguish the cases.This might be considered too significant a breakage, but it feels unsafe and strange if users have to use
const_cast
to be able to use these, and it might not be guaranteed that these passed arguments remain linked in the future since they aren't intended to be mutable based on the interfaceEdit: the ability to modify these values seems to be unreliable, and might not work correctly at least in godot-cpp, so this change appears more necessary, this could be this issue surfacing in godot-cpp (so would be specific to typed arrays):
Todo:
const
references godot-cpp#1471