From 0b6a8e201185e928ce31149b42d48c2ee6acf66f Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 7 Mar 2023 03:52:10 +0100 Subject: [PATCH] Fix an eventual crash and UDL empty button issue after changing language The bug was inserted by the following commit: https://github.com/notepad-plus-plus/notepad-plus-plus/commit/4d217387f129ee497e52227a47f4c5b38537edd7 Fix #13228 --- PowerEditor/src/localization.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 430aaca3e..7ce04c8da 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -681,10 +681,16 @@ void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) { - const wchar_t *nameW = wmc.char2wchar(name, _nativeLangEncoding); if (id == IDC_DOCK_BUTTON && userDefineDlg->isDocked()) - nameW = getAttrNameByIdStr(TEXT("Undock"), userDefineDlgNode, std::to_string(IDC_UNDOCK_BUTTON).c_str()).c_str(); - ::SetWindowText(hItem, nameW); + { + generic_string name = getAttrNameByIdStr(TEXT("Undock"), userDefineDlgNode, std::to_string(IDC_UNDOCK_BUTTON).c_str()); + ::SetWindowText(hItem, name.c_str()); + } + else + { + const wchar_t *nameW = wmc.char2wchar(name, _nativeLangEncoding); + ::SetWindowText(hItem, nameW); + } } } }