Skip to content

Commit 51a7ce4

Browse files
committed
Avoid empty text of language bar buttons since this will cause problems in Windows 10 (the button will disappear on update).
1 parent 616ad52 commit 51a7ce4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

LangBarButton.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,19 @@ const wchar_t* LangBarButton::text() const {
5959
}
6060

6161
void LangBarButton::setText(const wchar_t* text) {
62-
if(text) {
62+
if (text && text[0] != '\0') {
6363
wcsncpy(info_.szDescription, text, TF_LBI_DESC_MAXLEN - 1);
6464
info_.szDescription[TF_LBI_DESC_MAXLEN - 1] = 0;
6565
}
66-
else
67-
*info_.szDescription = 0;
66+
else {
67+
// NOTE: The language button text should NOT be empty.
68+
// Otherwise, when the button status or icon is changed after its creation,
69+
// the button will disappear temporarily in Windows 10 for unknown reason.
70+
// This can be considered a bug of Windows 10 and there does not seem to be a way to fix it.
71+
// So we need to avoid empty button text otherwise the language button won't work properly.
72+
// Here we use a space character to make the text non-empty to workaround the problem.
73+
wcscpy(info_.szDescription, L" ");
74+
}
6875
update(TF_LBI_TEXT);
6976
}
7077

0 commit comments

Comments
 (0)