[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

View File

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