Closed TyelorD closed 6 months ago
Alright, I've submitted PR #1890 with a fix for this bug. Feel free to pull my change in and then close this issue 🙂
static auto textField = axmol::ui::UICCTextField::create("Custom", "fonts/arial.ttf", 24);
Is the static
a typo?
static auto textField = axmol::ui::UICCTextField::create("Custom", "fonts/arial.ttf", 24);
Is the
static
a typo?
No, it was so that the reference to the textField pointer wasn't lost upon finishing the MainScene::init call, since the listener I wrote in step 2 uses that pointer reference in it's logic. This was just to avoid needing to have the textField declared in the header file, which would've been an additional file that needed changing for these repro steps.
(It probably wasn't needed here, since adding a Node as a child stops that pointer from being cleaned up. But I was just trying to be thorough here really. There is no harm in making textField a member field of MainScene either.)
No, it was so that the reference to the textField pointer wasn't lost upon finishing the MainScene::init call, since the listener I wrote in step 2 uses that pointer reference in it's logic.
I understand. Another option would have been to capture it by value in the lambda, so you wouldn't need the static:
mouseListener->onMouseUp = [textField] (ax::Event* event) {
I understand. Another option would have been to capture it by value in the lambda, so you wouldn't need the static:
mouseListener->onMouseUp = [textField] (ax::Event* event) {
Ah, that's a good point: I hadn't considered that. Thank you for pointing that out!
Steps to Reproduce:
Add a way to open and close the IME, e.g.:
If I manage to fix this crash I'll report back here, and likely post a pull request later for it too, but maybe someone here will beat me to fixing it 😅
Edit: A little more information, it looks like if I debug it line by line the crash doesn't occur and the TextField appears to work properly. When the crash does occur, V2F_C4B_T2F* point is still NULL after line #359.