Fix crash if session contained only sub-view files.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@222 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
harrybharry 2008-06-08 16:09:09 +00:00
parent 9448135225
commit 70ca7e3ff8

View File

@ -462,9 +462,9 @@ bool Notepad_plus::loadSession(Session & session)
{ {
bool allSessionFilesLoaded = true; bool allSessionFilesLoaded = true;
BufferID lastOpened = BUFFER_INVALID; BufferID lastOpened = BUFFER_INVALID;
int oldView = currentView();
size_t i = 0; size_t i = 0;
showView(MAIN_VIEW);
switchEditViewTo(MAIN_VIEW); //open files in main switchEditViewTo(MAIN_VIEW); //open files in main
for ( ; i < session.nbMainFiles() ; ) for ( ; i < session.nbMainFiles() ; )
{ {
@ -506,8 +506,8 @@ bool Notepad_plus::loadSession(Session & session)
} }
size_t k = 0; size_t k = 0;
//switchEditViewTo(SUB_VIEW); //open files in sub showView(SUB_VIEW);
_activeView = SUB_VIEW; switchEditViewTo(SUB_VIEW); //open files in sub
for ( ; k < session.nbSubFiles() ; ) for ( ; k < session.nbSubFiles() ; )
{ {
const char *pFn = session._subViewFiles[k]._fileName.c_str(); const char *pFn = session._subViewFiles[k]._fileName.c_str();
@ -558,7 +558,6 @@ bool Notepad_plus::loadSession(Session & session)
allSessionFilesLoaded = false; allSessionFilesLoaded = false;
} }
} }
_activeView = MAIN_VIEW;
_mainEditView.restoreCurrentPos(); _mainEditView.restoreCurrentPos();
_subEditView.restoreCurrentPos(); _subEditView.restoreCurrentPos();
@ -574,6 +573,11 @@ bool Notepad_plus::loadSession(Session & session)
else else
switchEditViewTo(MAIN_VIEW); switchEditViewTo(MAIN_VIEW);
if (canHideView(otherView()))
hideView(otherView());
else if (canHideView(currentView()))
hideView(currentView());
return allSessionFilesLoaded; return allSessionFilesLoaded;
} }