[BUG_FIXED] Fix the crash issue while config.xml and stylers.xml are not loaded.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1319 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2014-12-27 00:32:51 +00:00
parent 24c1dab2cb
commit 51a5fbfd59
3 changed files with 17 additions and 7 deletions

View File

@ -665,9 +665,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
//
StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers();
int i = globalStyles.getStylerIndexByID(STYLE_DEFAULT);
Style & style = globalStyles.getStyler(i);
(NppParameters::getInstance())->setCurrentDefaultFgColor(style._fgColor);
(NppParameters::getInstance())->setCurrentDefaultBgColor(style._bgColor);
if (i != -1)
{
Style & style = globalStyles.getStyler(i);
(NppParameters::getInstance())->setCurrentDefaultFgColor(style._fgColor);
(NppParameters::getInstance())->setCurrentDefaultBgColor(style._bgColor);
}
//
// launch the plugin dlg memorized at the last session

View File

@ -161,7 +161,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
patterns.push_back(TEXT("*.xml"));
generic_string nppDir = pNppParams->getNppPath();
#ifdef UNICODE
LocalizationSwitcher & localizationSwitcher = pNppParams->getLocalizationSwitcher();
wstring localizationDir = nppDir;
PathAppend(localizationDir, TEXT("localization\\"));
@ -171,7 +171,6 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
{
localizationSwitcher.addLanguageFromXml(fileNames[i].c_str());
}
#endif
fileNames.clear();
ThemeSwitcher & themeSwitcher = pNppParams->getThemeSwitcher();

View File

@ -397,7 +397,14 @@ public:
void setNbStyler(int nb) {_nbStyler = nb;};
Style & getStyler(int index) {
assert(index != -1);
assert(index >= 0 && index < SCE_STYLE_ARRAY_SIZE);
/*
if (index < 0 || index >= SCE_STYLE_ARRAY_SIZE)
{
Style s;
return s;
}
*/
return _styleArray[index];
};
@ -1534,7 +1541,8 @@ public:
};
void saveConfig_xml() {
_pXmlUserDoc->SaveFile();
if (_pXmlUserDoc)
_pXmlUserDoc->SaveFile();
};
generic_string getUserPath() const {