Fix crash regression due to ca8c302805

Crash regression has been inserted by #11258.

The 2GB+ adaptation has forced change in integers saving via TinyXML (now saved indirectly as strings). While the MapPosition part has been already fortified against possible missing session-file items, the Position part not. So implemented likewise the MapPosition way.

Fix #11325, close #11327
This commit is contained in:
xomx 2022-03-02 22:27:56 +01:00 committed by Don Ho
parent c19033c917
commit a419b41ed5
1 changed files with 25 additions and 8 deletions

View File

@ -2175,14 +2175,31 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session& s
if (fileName)
{
Position position;
position._firstVisibleLine = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("firstVisibleLine"))));
position._xOffset = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("xOffset"))));
position._startPos = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("startPos"))));
position._endPos = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("endPos"))));
position._selMode = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("selMode"))));
position._scrollWidth = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("scrollWidth"))));
position._offset = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("offset"))));
position._wrapCount = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("wrapCount"))));
const TCHAR* posStr = (childNode->ToElement())->Attribute(TEXT("firstVisibleLine"));
if (posStr)
position._firstVisibleLine = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("xOffset"));
if (posStr)
position._xOffset = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("startPos"));
if (posStr)
position._startPos = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("endPos"));
if (posStr)
position._endPos = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("selMode"));
if (posStr)
position._selMode = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("scrollWidth"));
if (posStr)
position._scrollWidth = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("offset"));
if (posStr)
position._offset = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("wrapCount"));
if (posStr)
position._wrapCount = static_cast<intptr_t>(_ttoi64(posStr));
MapPosition mapPosition;
const TCHAR* mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDisplayLine"));
if (mapPosStr)