mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-30 07:12:55 +00:00
fix: sign entry crash and remove blocking callback workaround
- Initialize m_iEditingLine to 0 in SignEntryMenu constructor (was uninitialized, causing out-of-bounds array access) - Add bounds check on m_iEditingLine before array access in callback - Only truncate sign text if longer than 15 chars (avoid padding) - Remove manual KeyboardCompleteSeedCallback call in LaunchMoreOptionsMenu (no longer needed since RequestKeyboard now fires callbacks asynchronously from Tick)
This commit is contained in:
parent
fe4c9bd36c
commit
e89198f56c
|
|
@ -644,7 +644,6 @@ void UIScene_LaunchMoreOptionsMenu::handlePress(F64 controlId, F64 childId) {
|
|||
0, 60,
|
||||
&UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback,
|
||||
this, C_4JInput::EKeyboardMode_Default);
|
||||
KeyboardCompleteSeedCallback(this, true);
|
||||
#endif
|
||||
} break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ UIScene_SignEntryMenu::UIScene_SignEntryMenu(int iPad, void* _initData,
|
|||
SignEntryScreenInput* initData = (SignEntryScreenInput*)_initData;
|
||||
m_sign = initData->sign;
|
||||
|
||||
m_iEditingLine = 0;
|
||||
m_bConfirmed = false;
|
||||
m_bIgnoreInput = false;
|
||||
|
||||
|
|
@ -141,12 +142,12 @@ int UIScene_SignEntryMenu::KeyboardCompleteCallback(void* lpParam, bool bRes) {
|
|||
// 4J HEG - No reason to set value if keyboard was cancelled
|
||||
UIScene_SignEntryMenu* pClass = (UIScene_SignEntryMenu*)lpParam;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
if (bRes) {
|
||||
if (bRes && pClass->m_iEditingLine >= 0 && pClass->m_iEditingLine < 4) {
|
||||
uint16_t pchText[128];
|
||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
||||
InputManager.GetText(pchText);
|
||||
std::wstring str = uint16_to_wstring(pchText);
|
||||
str.resize(15);
|
||||
if (str.size() > 15) str.resize(15);
|
||||
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(str);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue