[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:
parent
81e7b66ec5
commit
20f8196bec
@ -613,35 +613,41 @@ 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();
|
||||||
const char *fileName = fnNode->Value();
|
if (fnNode)
|
||||||
Position position;
|
|
||||||
(childNode->ToElement())->Attribute("firstVisibleLine", &position._firstVisibleLine);
|
|
||||||
(childNode->ToElement())->Attribute("xOffset", &position._xOffset);
|
|
||||||
(childNode->ToElement())->Attribute("startPos", &position._startPos);
|
|
||||||
(childNode->ToElement())->Attribute("endPos", &position._endPos);
|
|
||||||
|
|
||||||
sessionFileInfo sfi(fileName, position);
|
|
||||||
|
|
||||||
for (TiXmlNode *markNode = fnNode->NextSibling("Mark");
|
|
||||||
markNode ;
|
|
||||||
markNode = markNode->NextSibling("Mark") )
|
|
||||||
{
|
{
|
||||||
int lineNumber;
|
const char *fileName = fnNode->Value();
|
||||||
const char *lineNumberStr = (markNode->ToElement())->Attribute("line", &lineNumber);
|
|
||||||
if (lineNumberStr)
|
if (fileName)
|
||||||
{
|
{
|
||||||
sfi.marks.push_back(lineNumber);
|
Position position;
|
||||||
//::MessageBox(NULL, "coucou", "", MB_OK);
|
(childNode->ToElement())->Attribute("firstVisibleLine", &position._firstVisibleLine);
|
||||||
|
(childNode->ToElement())->Attribute("xOffset", &position._xOffset);
|
||||||
|
(childNode->ToElement())->Attribute("startPos", &position._startPos);
|
||||||
|
(childNode->ToElement())->Attribute("endPos", &position._endPos);
|
||||||
|
|
||||||
|
sessionFileInfo sfi(fileName, position);
|
||||||
|
|
||||||
|
for (TiXmlNode *markNode = fnNode->NextSibling("Mark");
|
||||||
|
markNode ;
|
||||||
|
markNode = markNode->NextSibling("Mark") )
|
||||||
|
{
|
||||||
|
int lineNumber;
|
||||||
|
const char *lineNumberStr = (markNode->ToElement())->Attribute("line", &lineNumber);
|
||||||
|
if (lineNumberStr)
|
||||||
|
{
|
||||||
|
sfi.marks.push_back(lineNumber);
|
||||||
|
//::MessageBox(NULL, "coucou", "", MB_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(*ptrSession)._files.push_back(sfi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileName)
|
|
||||||
(*ptrSession)._files.push_back(sfi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -763,9 +769,13 @@ 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 (uc.isValid())
|
if (cmdStr)
|
||||||
_userCommands.push_back(uc);
|
{
|
||||||
|
uc._cmd = cmdStr;
|
||||||
|
if (uc.isValid())
|
||||||
|
_userCommands.push_back(uc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1207,8 +1217,11 @@ void NppParameters::feedUserKeywordList(TiXmlNode *node)
|
|||||||
if (i != -1)
|
if (i != -1)
|
||||||
{
|
{
|
||||||
TiXmlNode *valueNode = childNode->FirstChild();
|
TiXmlNode *valueNode = childNode->FirstChild();
|
||||||
const char *kwl = (valueNode)?valueNode->Value():(strcmp(keywordsName, "Delimiters")?"":"000000");
|
if (valueNode)
|
||||||
strcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[i], kwl);
|
{
|
||||||
|
const char *kwl = (valueNode)?valueNode->Value():(strcmp(keywordsName, "Delimiters")?"":"000000");
|
||||||
|
strcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[i], kwl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1359,9 +1372,7 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode)
|
|||||||
TiXmlNode *v = styleNode->FirstChild();
|
TiXmlNode *v = styleNode->FirstChild();
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
//const char *keyWords = v->Value();
|
_styleArray[_nbStyler]._keywords = new string(v->Value());
|
||||||
//if (keyWords)
|
|
||||||
_styleArray[_nbStyler]._keywords = new string(v->Value());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_nbStyler++;
|
_nbStyler++;
|
||||||
|
Loading…
Reference in New Issue
Block a user