[BUG_FIX] Fix the crash problem while session.xml is corrupted.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@33 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2007-09-15 11:09:25 +00:00
parent 81e7b66ec5
commit 20f8196bec
1 changed files with 39 additions and 28 deletions

View File

@ -613,12 +613,18 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
{ {
(*ptrSession)._actifIndex = index; (*ptrSession)._actifIndex = index;
} }
for (TiXmlNode *childNode = sessionRoot->FirstChildElement("File"); for (TiXmlNode *childNode = sessionRoot->FirstChildElement("File");
childNode ; childNode ;
childNode = childNode->NextSibling("File") ) childNode = childNode->NextSibling("File") )
{ {
TiXmlNode *fnNode = childNode->FirstChild(); TiXmlNode *fnNode = childNode->FirstChild();
if (fnNode)
{
const char *fileName = fnNode->Value(); const char *fileName = fnNode->Value();
if (fileName)
{
Position position; Position position;
(childNode->ToElement())->Attribute("firstVisibleLine", &position._firstVisibleLine); (childNode->ToElement())->Attribute("firstVisibleLine", &position._firstVisibleLine);
(childNode->ToElement())->Attribute("xOffset", &position._xOffset); (childNode->ToElement())->Attribute("xOffset", &position._xOffset);
@ -639,10 +645,10 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
//::MessageBox(NULL, "coucou", "", MB_OK); //::MessageBox(NULL, "coucou", "", MB_OK);
} }
} }
if (fileName)
(*ptrSession)._files.push_back(sfi); (*ptrSession)._files.push_back(sfi);
} }
}
}
return true; return true;
} }
@ -763,13 +769,17 @@ void NppParameters::feedUserCmds(TiXmlNode *node)
TiXmlNode *aNode = childNode->FirstChild(); TiXmlNode *aNode = childNode->FirstChild();
if (aNode) if (aNode)
{ {
uc._cmd = aNode->Value(); const char *cmdStr = aNode->Value();
if (cmdStr)
{
uc._cmd = cmdStr;
if (uc.isValid()) if (uc.isValid())
_userCommands.push_back(uc); _userCommands.push_back(uc);
} }
} }
} }
} }
}
void NppParameters::feedPluginCustomizedCmds(TiXmlNode *node) void NppParameters::feedPluginCustomizedCmds(TiXmlNode *node)
{ {
@ -1207,11 +1217,14 @@ void NppParameters::feedUserKeywordList(TiXmlNode *node)
if (i != -1) if (i != -1)
{ {
TiXmlNode *valueNode = childNode->FirstChild(); TiXmlNode *valueNode = childNode->FirstChild();
if (valueNode)
{
const char *kwl = (valueNode)?valueNode->Value():(strcmp(keywordsName, "Delimiters")?"":"000000"); const char *kwl = (valueNode)?valueNode->Value():(strcmp(keywordsName, "Delimiters")?"":"000000");
strcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[i], kwl); strcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[i], kwl);
} }
} }
} }
}
void NppParameters::feedUserStyles(TiXmlNode *node) void NppParameters::feedUserStyles(TiXmlNode *node)
{ {
@ -1359,8 +1372,6 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode)
TiXmlNode *v = styleNode->FirstChild(); TiXmlNode *v = styleNode->FirstChild();
if (v) if (v)
{ {
//const char *keyWords = v->Value();
//if (keyWords)
_styleArray[_nbStyler]._keywords = new string(v->Value()); _styleArray[_nbStyler]._keywords = new string(v->Value());
} }
} }