Fix "Style Configurator..." command makes Notepad++ crash

If "stylers.xml" is not loaded, launching "Style Configurator..." command will make Notepad++ crash.
This commit fix this issue.

Fix #11812
This commit is contained in:
Don Ho 2022-07-02 17:19:17 +02:00
parent 4a32234e5f
commit 5c6fbd3310
4 changed files with 27 additions and 26 deletions

View File

@ -3347,10 +3347,17 @@ void Notepad_plus::command(int id)
case IDM_LANGSTYLE_CONFIG_DLG :
{
bool isFirstTime = !_configStyleDlg.isCreated();
_configStyleDlg.doDialog(_nativeLangSpeaker.isRTL());
if (isFirstTime)
_nativeLangSpeaker.changeConfigLang(_configStyleDlg.getHSelf());
if (!(NppParameters::getInstance()).isStylerDocLoaded())
{
// do nothing
}
else
{
bool isFirstTime = !_configStyleDlg.isCreated();
_configStyleDlg.doDialog(_nativeLangSpeaker.isRTL());
if (isFirstTime)
_nativeLangSpeaker.changeConfigLang(_configStyleDlg.getHSelf());
}
break;
}

View File

@ -429,48 +429,43 @@ struct GlobalOverride final
struct StyleArray
{
//auto size() const { return _styleVect.size(); }
auto begin() { return _styleVect.begin(); }
auto end() { return _styleVect.end(); }
void clear() { _styleVect.clear(); }
auto begin() { return _styleVect.begin(); };
auto end() { return _styleVect.end(); };
void clear() { _styleVect.clear(); };
Style & getStyler(size_t index)
{
Style& getStyler(size_t index) {
assert(index < _styleVect.size());
return _styleVect[index];
}
};
void addStyler(int styleID, TiXmlNode *styleNode);
void addStyler(int styleID, const generic_string & styleName)
{
void addStyler(int styleID, const generic_string& styleName) {
_styleVect.emplace_back();
Style & s = _styleVect.back();
Style& s = _styleVect.back();
s._styleID = styleID;
s._styleDesc = styleName;
s._fgColor = black;
s._bgColor = white;
}
};
Style * findByID(int id)
{
for (size_t i = 0 ; i < _styleVect.size() ; ++i)
Style* findByID(int id) {
for (size_t i = 0; i < _styleVect.size(); ++i)
{
if (_styleVect[i]._styleID == id)
return &(_styleVect[i]);
}
return nullptr;
}
};
Style * findByName(const generic_string & name)
{
for (size_t i = 0 ; i < _styleVect.size() ; ++i)
Style* findByName(const generic_string& name) {
for (size_t i = 0; i < _styleVect.size(); ++i)
{
if (_styleVect[i]._styleDesc == name)
return &(_styleVect[i]);
}
return nullptr;
}
};
protected:
std::vector<Style> _styleVect;
@ -1693,6 +1688,7 @@ public:
void setUdlXmlDirtyFromIndex(size_t i);
void setUdlXmlDirtyFromXmlDoc(const TiXmlDocument* xmlDoc);
void removeIndexFromXmlUdls(size_t i);
bool isStylerDocLoaded() const { return _pXmlUserStylerDoc != nullptr; };
private:
NppParameters();

View File

@ -2709,9 +2709,6 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
intptr_t start_mark = targetStart - lstart;
intptr_t end_mark = targetEnd - lstart;
//intptr_t start_mark2 = start_mark;
//intptr_t end_mark2 = end_mark;
pEditView->getGenericText(lineBuf, SC_SEARCHRESULT_LINEBUFFERMAXLENGTH, lstart, lend, &start_mark, &end_mark);
generic_string line = lineBuf;

View File

@ -147,6 +147,7 @@ private :
bool _isThemeDirty = false;
bool _isShownGOCtrls = false;
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);