mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-30 01:04:57 +02:00
Fix macro playing back crash issue
Fix crash issue while playing back macro if "find previous" and/or "find next" button actions are/is recorded. Also prevent from future crash if new commands in Find dialog are forgotten to be treated.
This commit is contained in:
parent
789cf387df
commit
9b565319e3
@ -2530,7 +2530,9 @@ void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus
|
|||||||
|
|
||||||
void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string stringValue)
|
void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string stringValue)
|
||||||
{
|
{
|
||||||
switch(cmd)
|
try
|
||||||
|
{
|
||||||
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case IDC_FRCOMMAND_INIT:
|
case IDC_FRCOMMAND_INIT:
|
||||||
_env = new FindOption;
|
_env = new FindOption;
|
||||||
@ -2539,16 +2541,16 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string s
|
|||||||
_env->_str2Search = stringValue;
|
_env->_str2Search = stringValue;
|
||||||
break;
|
break;
|
||||||
case IDC_FRCOMMAND_BOOLEANS:
|
case IDC_FRCOMMAND_BOOLEANS:
|
||||||
_env->_isWholeWord = ((intValue & IDF_WHOLEWORD)> 0);
|
_env->_isWholeWord = ((intValue & IDF_WHOLEWORD) > 0);
|
||||||
_env->_isMatchCase = ((intValue & IDF_MATCHCASE)> 0);
|
_env->_isMatchCase = ((intValue & IDF_MATCHCASE) > 0);
|
||||||
_env->_isRecursive = ((intValue & IDF_FINDINFILES_RECURSIVE_CHECK)> 0);
|
_env->_isRecursive = ((intValue & IDF_FINDINFILES_RECURSIVE_CHECK) > 0);
|
||||||
_env->_isInHiddenDir = ((intValue & IDF_FINDINFILES_INHIDDENDIR_CHECK)> 0);
|
_env->_isInHiddenDir = ((intValue & IDF_FINDINFILES_INHIDDENDIR_CHECK) > 0);
|
||||||
_env->_doPurge = ((intValue & IDF_PURGE_CHECK)> 0);
|
_env->_doPurge = ((intValue & IDF_PURGE_CHECK) > 0);
|
||||||
_env->_doMarkLine = ((intValue & IDF_MARKLINE_CHECK)> 0);
|
_env->_doMarkLine = ((intValue & IDF_MARKLINE_CHECK) > 0);
|
||||||
_env->_isInSelection = ((intValue & IDF_IN_SELECTION_CHECK)> 0);
|
_env->_isInSelection = ((intValue & IDF_IN_SELECTION_CHECK) > 0);
|
||||||
_env->_isWrapAround = ((intValue & IDF_WRAP)> 0);
|
_env->_isWrapAround = ((intValue & IDF_WRAP) > 0);
|
||||||
_env->_whichDirection = ((intValue & IDF_WHICH_DIRECTION)> 0);
|
_env->_whichDirection = ((intValue & IDF_WHICH_DIRECTION) > 0);
|
||||||
_env->_dotMatchesNewline = ((intValue & IDF_REDOTMATCHNL)> 0);
|
_env->_dotMatchesNewline = ((intValue & IDF_REDOTMATCHNL) > 0);
|
||||||
break;
|
break;
|
||||||
case IDNORMAL:
|
case IDNORMAL:
|
||||||
_env->_searchType = static_cast<SearchType>(intValue);
|
_env->_searchType = static_cast<SearchType>(intValue);
|
||||||
@ -2565,13 +2567,32 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string s
|
|||||||
case IDC_FRCOMMAND_EXEC:
|
case IDC_FRCOMMAND_EXEC:
|
||||||
{
|
{
|
||||||
NppParameters *nppParamInst = NppParameters::getInstance();
|
NppParameters *nppParamInst = NppParameters::getInstance();
|
||||||
switch(intValue)
|
switch (intValue)
|
||||||
{
|
{
|
||||||
case IDOK:
|
case IDOK:
|
||||||
nppParamInst->_isFindReplacing = true;
|
nppParamInst->_isFindReplacing = true;
|
||||||
processFindNext(_env->_str2Search.c_str());
|
processFindNext(_env->_str2Search.c_str());
|
||||||
nppParamInst->_isFindReplacing = false;
|
nppParamInst->_isFindReplacing = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDC_FINDNEXT:
|
||||||
|
{
|
||||||
|
nppParamInst->_isFindReplacing = true;
|
||||||
|
_options._whichDirection = DIR_DOWN;
|
||||||
|
processFindNext(_env->_str2Search.c_str());
|
||||||
|
nppParamInst->_isFindReplacing = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDC_FINDPREV:
|
||||||
|
{
|
||||||
|
nppParamInst->_isFindReplacing = true;
|
||||||
|
_env->_whichDirection = DIR_UP;
|
||||||
|
processFindNext(_env->_str2Search.c_str());
|
||||||
|
nppParamInst->_isFindReplacing = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case IDREPLACE:
|
case IDREPLACE:
|
||||||
nppParamInst->_isFindReplacing = true;
|
nppParamInst->_isFindReplacing = true;
|
||||||
processReplace(_env->_str2Search.c_str(), _env->_str4Replace.c_str(), _env);
|
processReplace(_env->_str2Search.c_str(), _env->_str4Replace.c_str(), _env);
|
||||||
@ -2587,25 +2608,25 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string s
|
|||||||
findAllIn(FILES_IN_DIR);
|
findAllIn(FILES_IN_DIR);
|
||||||
nppParamInst->_isFindReplacing = false;
|
nppParamInst->_isFindReplacing = false;
|
||||||
break;
|
break;
|
||||||
case IDC_REPLACE_OPENEDFILES :
|
case IDC_REPLACE_OPENEDFILES:
|
||||||
nppParamInst->_isFindReplacing = true;
|
nppParamInst->_isFindReplacing = true;
|
||||||
replaceAllInOpenedDocs();
|
replaceAllInOpenedDocs();
|
||||||
nppParamInst->_isFindReplacing = false;
|
nppParamInst->_isFindReplacing = false;
|
||||||
break;
|
break;
|
||||||
case IDD_FINDINFILES_FIND_BUTTON :
|
case IDD_FINDINFILES_FIND_BUTTON:
|
||||||
nppParamInst->_isFindReplacing = true;
|
nppParamInst->_isFindReplacing = true;
|
||||||
findAllIn(FILES_IN_DIR);
|
findAllIn(FILES_IN_DIR);
|
||||||
nppParamInst->_isFindReplacing = false;
|
nppParamInst->_isFindReplacing = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDD_FINDINFILES_REPLACEINFILES :
|
case IDD_FINDINFILES_REPLACEINFILES:
|
||||||
{
|
{
|
||||||
generic_string msg = TEXT("Are you sure you want to replace all occurrences in :\r");
|
generic_string msg = TEXT("Are you sure you want to replace all occurrences in :\r");
|
||||||
msg += _env->_directory;
|
msg += _env->_directory;
|
||||||
msg += TEXT("\rfor file type : ");
|
msg += TEXT("\rfor file type : ");
|
||||||
msg += (_env->_filters[0])?_env->_filters:TEXT("*.*");
|
msg += (_env->_filters[0]) ? _env->_filters : TEXT("*.*");
|
||||||
|
|
||||||
if (::MessageBox(_hParent, msg.c_str(), TEXT("Are you sure?"), MB_OKCANCEL|MB_DEFBUTTON2) == IDOK)
|
if (::MessageBox(_hParent, msg.c_str(), TEXT("Are you sure?"), MB_OKCANCEL | MB_DEFBUTTON2) == IDOK)
|
||||||
{
|
{
|
||||||
nppParamInst->_isFindReplacing = true;
|
nppParamInst->_isFindReplacing = true;
|
||||||
::SendMessage(_hParent, WM_REPLACEINFILES, 0, 0);
|
::SendMessage(_hParent, WM_REPLACEINFILES, 0, 0);
|
||||||
@ -2613,7 +2634,7 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string s
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IDREPLACEALL :
|
case IDREPLACEALL:
|
||||||
{
|
{
|
||||||
nppParamInst->_isFindReplacing = true;
|
nppParamInst->_isFindReplacing = true;
|
||||||
(*_ppEditView)->execute(SCI_BEGINUNDOACTION);
|
(*_ppEditView)->execute(SCI_BEGINUNDOACTION);
|
||||||
@ -2644,7 +2665,7 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string s
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IDCCOUNTALL :
|
case IDCCOUNTALL:
|
||||||
{
|
{
|
||||||
int nbCounted = processAll(ProcessCountAll, _env);
|
int nbCounted = processAll(ProcessCountAll, _env);
|
||||||
generic_string result;
|
generic_string result;
|
||||||
@ -2701,9 +2722,11 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string s
|
|||||||
setStatusbarMessage(result, FSMessage);
|
setStatusbarMessage(result, FSMessage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Internal error: unknown saved command!");
|
throw std::runtime_error("Internal error: unknown saved command!");
|
||||||
}
|
}
|
||||||
|
|
||||||
delete _env;
|
delete _env;
|
||||||
_env = &_options;
|
_env = &_options;
|
||||||
break;
|
break;
|
||||||
@ -2711,6 +2734,11 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string s
|
|||||||
default:
|
default:
|
||||||
throw std::runtime_error("Internal error: unknown SnR command!");
|
throw std::runtime_error("Internal error: unknown SnR command!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (std::runtime_error err)
|
||||||
|
{
|
||||||
|
MessageBoxA(NULL, err.what(), "Play Macro Exception", MB_OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDlg::setFindInFilesDirFilter(const TCHAR *dir, const TCHAR *filters)
|
void FindReplaceDlg::setFindInFilesDirFilter(const TCHAR *dir, const TCHAR *filters)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user