Skip to content

Commit

Permalink
Fix the double notifications bug
Browse files Browse the repository at this point in the history
  • Loading branch information
donho committed Aug 28, 2024
1 parent 52f306e commit 68748a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
7 changes: 0 additions & 7 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7248,13 +7248,6 @@ bool Notepad_plus::reloadLang()
}

_lastRecentFileList.setLangEncoding(_nativeLangSpeaker.getLangEncoding());

SCNotification scnN{};
scnN.nmhdr.code = NPPN_NATIVELANGCHANGED;
scnN.nmhdr.hwndFrom = _pPublicInterface->getHSelf();
scnN.nmhdr.idFrom = 0;
_pluginsManager.notify(&scnN);

return true;
}

Expand Down
10 changes: 10 additions & 0 deletions PowerEditor/src/NppBigSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,16 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_INTERNAL_RELOADNATIVELANG:
{
reloadLang();

bool doNotif = wParam;
if (doNotif)
{
SCNotification scnN{};
scnN.nmhdr.code = NPPN_NATIVELANGCHANGED;
scnN.nmhdr.hwndFrom = _pPublicInterface->getHSelf();
scnN.nmhdr.idFrom = 0;
_pluginsManager.notify(&scnN);
}
return TRUE;
}

Expand Down
9 changes: 5 additions & 4 deletions PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,15 +812,16 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETLBTEXT, index, reinterpret_cast<LPARAM>(langName));
if (langName[0])
{
// Make English as basic language
if (localizationSwitcher.switchToLang(L"English"))
// Make English as basic language, but if we switch from another language to English, we can skip it
if ((lstrcmpW(langName, L"English") != 0) && localizationSwitcher.switchToLang(L"English"))
{
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RELOADNATIVELANG, 0, 0);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RELOADNATIVELANG, FALSE, 0);
}

// Change the language
if (localizationSwitcher.switchToLang(langName))
{
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RELOADNATIVELANG, 0, 0);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RELOADNATIVELANG, TRUE, 0);
::InvalidateRect(_hParent, NULL, TRUE);
}
}
Expand Down

0 comments on commit 68748a8

Please sign in to comment.