Fix user command save problem on exit.

This commit is contained in:
Don Ho 2015-09-16 17:56:12 +02:00
parent 4df21f16dc
commit 69a57e5e8d
2 changed files with 8 additions and 5 deletions

View File

@ -3878,7 +3878,8 @@ bool Notepad_plus::saveScintillaParams()
bool Notepad_plus::addCurrentMacro() bool Notepad_plus::addCurrentMacro()
{ {
vector<MacroShortcut> & theMacros = (NppParameters::getInstance())->getMacroList(); NppParameters* nppParams = NppParameters::getInstance();
vector<MacroShortcut> & theMacros = nppParams->getMacroList();
int nbMacro = theMacros.size(); int nbMacro = theMacros.size();
@ -3897,7 +3898,7 @@ bool Notepad_plus::addCurrentMacro()
// Insert the separator and modify/delete command // Insert the separator and modify/delete command
::InsertMenu(hMacroMenu, posBase + nbMacro + 1, MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hMacroMenu, posBase + nbMacro + 1, MF_BYPOSITION, (unsigned int)-1, 0);
NativeLangSpeaker *pNativeLangSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); NativeLangSpeaker *pNativeLangSpeaker = nppParams->getNativeLangSpeaker();
generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO); generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO);
if (nativeLangShortcutMapperMacro == TEXT("")) if (nativeLangShortcutMapperMacro == TEXT(""))
nativeLangShortcutMapperMacro = TEXT("Modify Shortcut/Delete Macro..."); nativeLangShortcutMapperMacro = TEXT("Modify Shortcut/Delete Macro...");
@ -3907,7 +3908,7 @@ bool Notepad_plus::addCurrentMacro()
theMacros.push_back(ms); theMacros.push_back(ms);
::InsertMenu(hMacroMenu, posBase + nbMacro, MF_BYPOSITION, cmdID, ms.toMenuItemString().c_str()); ::InsertMenu(hMacroMenu, posBase + nbMacro, MF_BYPOSITION, cmdID, ms.toMenuItemString().c_str());
_accelerator.updateShortcuts(); _accelerator.updateShortcuts();
(NppParameters::getInstance())->setShortcutDirty(); nppParams->setShortcutDirty();
return true; return true;
} }
return false; return false;

View File

@ -250,18 +250,20 @@ INT_PTR CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
theUserCmds.push_back(uc); theUserCmds.push_back(uc);
::InsertMenu(hRunMenu, posBase + nbCmd, MF_BYPOSITION, cmdID, uc.toMenuItemString().c_str()); ::InsertMenu(hRunMenu, posBase + nbCmd, MF_BYPOSITION, cmdID, uc.toMenuItemString().c_str());
NppParameters* nppParams = NppParameters::getInstance();
if (nbCmd == 0) if (nbCmd == 0)
{ {
// Insert the separator and modify/delete command // Insert the separator and modify/delete command
::InsertMenu(hRunMenu, posBase + nbCmd + 1, MF_BYPOSITION, (unsigned int)-1, 0); ::InsertMenu(hRunMenu, posBase + nbCmd + 1, MF_BYPOSITION, (unsigned int)-1, 0);
NativeLangSpeaker *pNativeLangSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); NativeLangSpeaker *pNativeLangSpeaker = nppParams->getNativeLangSpeaker();
generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO); generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO);
if (nativeLangShortcutMapperMacro == TEXT("")) if (nativeLangShortcutMapperMacro == TEXT(""))
nativeLangShortcutMapperMacro = TEXT("Modify Shortcut/Delete Command..."); nativeLangShortcutMapperMacro = TEXT("Modify Shortcut/Delete Command...");
::InsertMenu(hRunMenu, posBase + nbCmd + 2, MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, nativeLangShortcutMapperMacro.c_str()); ::InsertMenu(hRunMenu, posBase + nbCmd + 2, MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, nativeLangShortcutMapperMacro.c_str());
} }
(NppParameters::getInstance())->getAccelerator()->updateShortcuts(); nppParams->getAccelerator()->updateShortcuts();
nppParams->setShortcutDirty();
} }
return TRUE; return TRUE;
} }