Rework the way custom class instances are created from C++#408
Merged
Zylann merged 1 commit intogodotengine:masterfrom Jun 5, 2020
Merged
Rework the way custom class instances are created from C++#408Zylann merged 1 commit intogodotengine:masterfrom
Zylann merged 1 commit intogodotengine:masterfrom
Conversation
e89ee90 to
a493928
Compare
Collaborator
Author
|
Worked around the last leak, things should work fine now. |
BastiaanOlij
approved these changes
Jun 2, 2020
Collaborator
BastiaanOlij
left a comment
There was a problem hiding this comment.
I'm happy to try these changes merged into master. Do fix up the clang-format issues first though
Member
|
Try to rebase after #409. |
Collaborator
Author
|
Fixed formatting. |
This was referenced Jun 5, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a new take that can replace #401 and #346 (it goes a long way at this point).
Should fix #397, #343, #215.
PR #350 is no longer needed, as well as godotengine/godot#33532 and godotengine/godot-headers#60, so it should also be easier to merge.
PR #346 might also be no longer needed, if it's about the same issue? Though I don't really understand the change it does.
To understand what's going on and why this is yet another PR, I wrote a summary here: godotengine/godot#33532 (comment)
This PR avoids the original source of the leak by directly creating the new instance, without going through reference initialization (which is then done by us down the road), so it behaves consistently like in engine and workarounds of the previous PRs should not be needed.
Object::set_script()instead ofNativeScript::new(), as is done in the D and Rust bindings (thanks @toasteater and @sheepandshepherd for the help).GDNativeLibraryno longer causes a leak (worked around with C API, see Instance binding data on GDNativeLibrary objects never gets freed godot#39181)GODOT_CLASSso it's not written twicedetailnamespace, as it's meant for internal useas()to its true meaning (not 100% sure on that. I did this when looking at the only places it was used, please confirm)godotnamespaceNote: the only downside of
set_scriptis that we can't have this fix and have constructor arguments at the same time (as proposed in #293). However constructor arguments were already not supported so this doesn't break any compatibility and should be investigated in a future PR (which could involve PR to Godot), as I think the fix has much higher priority.