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:
parent
4a32234e5f
commit
5c6fbd3310
|
@ -3347,10 +3347,17 @@ void Notepad_plus::command(int id)
|
||||||
|
|
||||||
case IDM_LANGSTYLE_CONFIG_DLG :
|
case IDM_LANGSTYLE_CONFIG_DLG :
|
||||||
{
|
{
|
||||||
bool isFirstTime = !_configStyleDlg.isCreated();
|
if (!(NppParameters::getInstance()).isStylerDocLoaded())
|
||||||
_configStyleDlg.doDialog(_nativeLangSpeaker.isRTL());
|
{
|
||||||
if (isFirstTime)
|
// do nothing
|
||||||
_nativeLangSpeaker.changeConfigLang(_configStyleDlg.getHSelf());
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool isFirstTime = !_configStyleDlg.isCreated();
|
||||||
|
_configStyleDlg.doDialog(_nativeLangSpeaker.isRTL());
|
||||||
|
if (isFirstTime)
|
||||||
|
_nativeLangSpeaker.changeConfigLang(_configStyleDlg.getHSelf());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -429,48 +429,43 @@ struct GlobalOverride final
|
||||||
|
|
||||||
struct StyleArray
|
struct StyleArray
|
||||||
{
|
{
|
||||||
//auto size() const { return _styleVect.size(); }
|
auto begin() { return _styleVect.begin(); };
|
||||||
auto begin() { return _styleVect.begin(); }
|
auto end() { return _styleVect.end(); };
|
||||||
auto end() { return _styleVect.end(); }
|
void clear() { _styleVect.clear(); };
|
||||||
void clear() { _styleVect.clear(); }
|
|
||||||
|
|
||||||
Style & getStyler(size_t index)
|
Style& getStyler(size_t index) {
|
||||||
{
|
|
||||||
assert(index < _styleVect.size());
|
assert(index < _styleVect.size());
|
||||||
return _styleVect[index];
|
return _styleVect[index];
|
||||||
}
|
};
|
||||||
|
|
||||||
void addStyler(int styleID, TiXmlNode *styleNode);
|
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();
|
_styleVect.emplace_back();
|
||||||
Style & s = _styleVect.back();
|
Style& s = _styleVect.back();
|
||||||
s._styleID = styleID;
|
s._styleID = styleID;
|
||||||
s._styleDesc = styleName;
|
s._styleDesc = styleName;
|
||||||
s._fgColor = black;
|
s._fgColor = black;
|
||||||
s._bgColor = white;
|
s._bgColor = white;
|
||||||
}
|
};
|
||||||
|
|
||||||
Style * findByID(int id)
|
Style* findByID(int id) {
|
||||||
{
|
for (size_t i = 0; i < _styleVect.size(); ++i)
|
||||||
for (size_t i = 0 ; i < _styleVect.size() ; ++i)
|
|
||||||
{
|
{
|
||||||
if (_styleVect[i]._styleID == id)
|
if (_styleVect[i]._styleID == id)
|
||||||
return &(_styleVect[i]);
|
return &(_styleVect[i]);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
};
|
||||||
|
|
||||||
Style * findByName(const generic_string & name)
|
Style* findByName(const generic_string& name) {
|
||||||
{
|
for (size_t i = 0; i < _styleVect.size(); ++i)
|
||||||
for (size_t i = 0 ; i < _styleVect.size() ; ++i)
|
|
||||||
{
|
{
|
||||||
if (_styleVect[i]._styleDesc == name)
|
if (_styleVect[i]._styleDesc == name)
|
||||||
return &(_styleVect[i]);
|
return &(_styleVect[i]);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<Style> _styleVect;
|
std::vector<Style> _styleVect;
|
||||||
|
@ -1693,6 +1688,7 @@ public:
|
||||||
void setUdlXmlDirtyFromIndex(size_t i);
|
void setUdlXmlDirtyFromIndex(size_t i);
|
||||||
void setUdlXmlDirtyFromXmlDoc(const TiXmlDocument* xmlDoc);
|
void setUdlXmlDirtyFromXmlDoc(const TiXmlDocument* xmlDoc);
|
||||||
void removeIndexFromXmlUdls(size_t i);
|
void removeIndexFromXmlUdls(size_t i);
|
||||||
|
bool isStylerDocLoaded() const { return _pXmlUserStylerDoc != nullptr; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NppParameters();
|
NppParameters();
|
||||||
|
|
|
@ -2709,9 +2709,6 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
intptr_t start_mark = targetStart - lstart;
|
intptr_t start_mark = targetStart - lstart;
|
||||||
intptr_t end_mark = targetEnd - 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);
|
pEditView->getGenericText(lineBuf, SC_SEARCHRESULT_LINEBUFFERMAXLENGTH, lstart, lend, &start_mark, &end_mark);
|
||||||
|
|
||||||
generic_string line = lineBuf;
|
generic_string line = lineBuf;
|
||||||
|
|
|
@ -147,6 +147,7 @@ private :
|
||||||
bool _isThemeDirty = false;
|
bool _isThemeDirty = false;
|
||||||
bool _isShownGOCtrls = false;
|
bool _isShownGOCtrls = false;
|
||||||
|
|
||||||
|
|
||||||
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
|
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue