-
-
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
Add shorthand for using singleton string names #81303
Add shorthand for using singleton string names #81303
Conversation
5417652
to
8c55241
Compare
8c55241
to
c354dcb
Compare
d2b32fa
to
5140ec1
Compare
67ca79c
to
0e4907d
Compare
0e4907d
to
3805efd
Compare
59200d8
to
056ce4a
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.
Tested locally, it mostly works as expected.
This reduces binary size by about 8 KB too (optimized Linux x86_64 editor).
106,980,384 godot.linuxbsd.editor.x86_64 <-- This PR
106,988,576 godot.linuxbsd.editor.x86_64.master
However, I get a series of errors when exiting the editor. This occurs on any project, even an empty project:
ERROR: Attempt to disconnect a nonexistent connection from '@CreateDialog@5292:<CreateDialog#505883418985>'. Signal: 'confirmed', callable: 'CreateDialog::_confirmed'.
at: _disconnect (./core/object/object.cpp:1416)
ERROR: Attempt to disconnect a nonexistent connection from '@CreateDialog@10229:<CreateDialog#775476516600>'. Signal: 'confirmed', callable: 'CreateDialog::_confirmed'.
at: _disconnect (./core/object/object.cpp:1416)
ERROR: Attempt to disconnect a nonexistent connection from '@CreateDialog@6763:<CreateDialog#575894745070>'. Signal: 'confirmed', callable: 'CreateDialog::_confirmed'.
at: _disconnect (./core/object/object.cpp:1416)
ERROR: Attempt to disconnect a nonexistent connection from '@CreateDialog@6344:<CreateDialog#556684831719>'. Signal: 'confirmed', callable: 'CreateDialog::_confirmed'.
at: _disconnect (./core/object/object.cpp:1416)
ERROR: Attempt to disconnect a nonexistent connection from '@CreateDialog@6197:<CreateDialog#550175271553>'. Signal: 'confirmed', callable: 'CreateDialog::_confirmed'.
at: _disconnect (./core/object/object.cpp:1416)
ERROR: Attempt to disconnect a nonexistent connection from '@EditorFileSystem@3:<EditorFileSystem#28269610226>'. Signal: 'filesystem_changed', callable: 'EditorDirDialog::reload'.
at: _disconnect (./core/object/object.cpp:1416)
ERROR: Attempt to disconnect a nonexistent connection from '@CreateDialog@4543:<CreateDialog#471121025568>'. Signal: 'confirmed', callable: 'CreateDialog::_confirmed'.
at: _disconnect (./core/object/object.cpp:1416)
ERROR: Attempt to disconnect a nonexistent connection from '@CreateDialog@4361:<CreateDialog#462698862674>'. Signal: 'confirmed', callable: 'CreateDialog::_confirmed'.
at: _disconnect (./core/object/object.cpp:1416)
I can't reproduce the errors. Are you sure they are caused by this PR? Any chance for their stack trace? |
056ce4a
to
a262d2d
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.
I like the change, and it seems to work fine on my end from a quick test.
Would be good if @Calinou could test again and see if he reproduces the error about missing signal connections.
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 locally (rebased on top of master
bdc0316), it works as expected now. I can't reproduce the errors on exit anymore.
Thanks! |
StringName changed; | ||
StringName _script; | ||
StringName script; |
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.
Introduced a conflict with:
Writing up a fix
Follow-up to #80573
This PR adds
CoreStringName()
andSceneStringName()
macros as a shorthand forCoreStringNames::get_singleton()->
andSceneStringNames::get_singleton()->
. It makes the singleton string names easier to use and code is cleaner.I also applied some minor cleanup:
___pdcdata
,__getvar
_script
for"script"
For the last point I had to make some exceptions, because the actual name conflicted with a C++ keyword. I changed the name from
_name
toname_
(up to discussion), to make it more clear that underscore is not part of the name.My plan after that is to replace all usage of "strings" and SNAME("strings") with their singleton equivalent if it exists already. Right now they are used inconsistently.
Another thing is that some names are used only once. I think they can be replaced with
SNAME()
; it didn't exist when they were created.Production edit: closes godotengine/godot-roadmap#3