-
-
Notifications
You must be signed in to change notification settings - Fork 260
Register custom icons in class macro #1407
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
base: master
Are you sure you want to change the base?
Conversation
71f754c to
5fbf8fc
Compare
|
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1407 |
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.
First of all – thanks!!!!
-
ICON_STRINGS_BY_NAMEwhich keepsGStrings is not being pruned during deinit of the library, which means memory leak during, for example, hot reload.
Please check it and report if I'm wrong. See alsocleanup
Storing GStrings to keep them valid as long as library is loaded is fine, just don't leak them. -
This feature is not tested at all – I think I would create new file in
itest/rust/src/register_testsand annotate it with#. Tests allows us to watch for memory leaks, shield us against regression etc – additionally we need to guarantee that all the used APIs are OKay and give an example how they can be used. -
I would remove
ExtensionConfig(up to discussion) – right now its only purpose is to set default fallback icon for classes, which will be useless and counter-productive after 4.6: godotengine/godot#108607. I'm also finding it a little confusing (like, docs mention tools and build scripts – how would I even use it there?) -
#[class(icon = MY_ICON)]is not documented in#[derive(GodotClass)]docs. -
Address various silly things, like
SAFETYremarks under now-safe blocks, comments not ending with a dot etc.
|
This is great feedback, I'll make some changes tomorrow and get back to you. |
5fbf8fc to
8c511a5
Compare
|
I have removed the entire gdextension icon section; I can always create another PR with that in mind once we have a better idea. Just poking around At the moment the integration tests I've added are just checking Thanks! |
On that note, I believe it would be better to add a virtual method returning a string, rather than do this via proc-macro. While it's inconsistent with the
|
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.
looks pretty much OK, I'll give it a proper run and see if there are any weird issues/quirks – I think we should move icon GString to LoadedClass, but it shouldn't change too much in the implementation/behavior itself.
I think using
IMO checking if Godot is able to register given class should be enough – ideally we should be able to check if icon has been properly set on Godot's side, but (currently) we don't have any API to access that. |
b7bc46a to
08ccba9
Compare
|
Ok, thank you both for the feedback, I've reworked this a little bit:
Should I add Thanks! |
08ccba9 to
3623307
Compare
Thanks for the awesome work everyone puts into this project. This is my first rust contribution, so I'm keen to get some feedback and learn.
This pull request closes issue #1200.
It adds a new
iconattribute to the#[class]macro.Because the icon attribute is a
TokenStream, we can also write:Considerations
GDExtensionClassCreationInfo4::icon_path.gdextensionfile[icon]section declarations seem to take precedenceThanks!