-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Retain _debugDrawNode in Label #1890
Retain _debugDrawNode in Label #1890
Conversation
This fixes a memory corruption bug and resulting crash in the TextFieldTTF (and likely other TextField classes) where the _debugDrawNode wasn't being retained, and the label isn't added to the scene for a TextField, but is maintained by the TextField. This caused _debugDrawNode in the Label class to get cleaned up, even though Label still thought it had a valid reference to a DrawNode.
I should note, that while this does fix the crash I was seeing, it also causes the TextField to lose its debug bounding box still. I'm not sure why that would be the case however. |
That is strange. The DrawNode is created then added as a child:
At the end of that line, the
The only reason Explicitly retaining and releasing is the right thing to do when keeping references to such objects, but in this case, it may also be covering up the root cause of the issue that you're facing.
Do you mean it has been removed as a child of Label? Perhaps finding out why this is the case will lead you to the source of the problem, because retaining and releasing is not going to fix the issue of the DrawNode being removed as a child of the label. It would just be a holding a reference to an object that is no longer in the scene, which may explain why you're not seeing anything being drawn on the screen by the DrawNode. |
The call to Putting a memory breakpoint on the In addition to your change regarding retaining/releasing, you would also need to add code in
Also it would need to be added to
In order for the bit of code in It is also a little odd why the With all the changes combined, the text box outline will no longer disappear. |
Maybe But I think it's only a symptom... the actual bug is that |
Try use UITextFieldEx instead, we should deprecated TextFieldEx has better cursor support |
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.
Not actually solve issue
@TyelorD Alternative solution to what I mentioned previously is precisely what @smilediver pointed out, which is to call For this, ignore the changes in my previous post, and also remove any So in the end, the only modifications would just be the addition of the
|
Alright, I think that sounds like the "more proper" solution of the two proposed fixes for my change, so I changed Label.cpp to only retain/release the One thing to note that we may want to amend in the future (or at least discuss how to handle) is that the insertion cursor renders outside the labels bounding box, and so it's not captured by the |
|
@TyelorD Is there anything else to be added to this PR? |
Describe your changes
This fixes the memory corruption bug and resulting crash I outlined in the TextFieldTTF (and likely other TextField classes) where the _debugDrawNode wasn't being retained, and the label isn't added to the scene for a TextField, but is maintained by the TextField. This caused _debugDrawNode in the Label class to get cleaned up, even though Label still thought it had a valid reference to a DrawNode.
Issue ticket number and link
#1889
Checklist before requesting a review
For each PR
Add Copyright if it missed:
-
"Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."
I have performed a self-review of my code.
Optional:
For core/new feature PR