From e89198f56cd96520f26c89b659a4b78facd9f503 Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Mon, 30 Mar 2026 13:38:50 +1100 Subject: [PATCH] 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) --- .../Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp | 1 - .../Platform/Common/UI/UIScene_SignEntryMenu.cpp | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index 8a7e7efda..fdd814ab7 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -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; } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp index 70288fb1f..ad79dc97a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp @@ -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;