Skip to content

Commit

Permalink
Merge branch 'jl/LH-2/fix_crash_user_def_style' into pu
Browse files Browse the repository at this point in the history
* jl/LH-2/fix_crash_user_def_style:
  User defined languages: fix undefined lang crash.

[#2 state:proposed]
  • Loading branch information
Thell Fowler committed Oct 23, 2009
2 parents 75a97c7 + 4275494 commit a7bb650
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8030,7 +8030,12 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}

// Add User Define Languages Entry
int udlpos = ::GetMenuItemCount(hLangMenu) - 1;
int udlpos = ::GetMenuItemCount(hLangMenu);

if (pNppParam->getNbUserLang() > 0)
{
::InsertMenu(hLangMenu, udlpos++, MF_BYPOSITION|MF_SEPARATOR, 0, TEXT(""));
}

for (int i = 0 ; i < pNppParam->getNbUserLang() ; i++)
{
Expand Down
4 changes: 0 additions & 4 deletions PowerEditor/src/Notepad_plus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,6 @@ BEGIN
MENUITEM "Verilog", IDM_LANG_VERILOG
MENUITEM "XML", IDM_LANG_XML
MENUITEM "YAML", IDM_LANG_YAML
MENUITEM SEPARATOR
MENUITEM "User-Defined", IDM_LANG_USER
END
POPUP "&Language"
BEGIN
Expand Down Expand Up @@ -530,8 +528,6 @@ BEGIN
END
MENUITEM "XML", IDM_LANG_XML
MENUITEM "YAML", IDM_LANG_YAML
MENUITEM SEPARATOR
MENUITEM "User-Defined", IDM_LANG_USER
END

POPUP "Se&ttings"
Expand Down
8 changes: 8 additions & 0 deletions PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,9 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM
::PostMessage(_hSelf, WM_COMMAND, IDC_RENAME_BUTTON, 0);
return TRUE;
}

bool needMenuSeparator = (pNppParam->getNbUserLang() == 0);

//add current language in userLangArray at the end as a new lang
UserLangContainer & userLang = (wParam == IDC_SAVEAS_BUTTON)?pNppParam->getULCFromIndex(i-1):*_pCurrentUserLang;
int newIndex = pNppParam->addUserLangToEnd(userLang, newName);
Expand All @@ -1748,6 +1751,11 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM

//add new language name in langMenu
HWND hNpp = ::GetParent(_hSelf);
if (needMenuSeparator)
{
::InsertMenu(::GetSubMenu((HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), IDM_LANG_USER, MF_BYPOSITION|MF_SEPARATOR, 0, TEXT(""));
}

::InsertMenu(::GetSubMenu((HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), IDM_LANG_USER + newIndex /*+ 1*/, MF_BYCOMMAND, IDM_LANG_USER + newIndex + 1, newName);
::DrawMenuBar(hNpp);
}
Expand Down

0 comments on commit a7bb650

Please sign in to comment.