Fix a few issues with session/lastopenedfiles, Bo Peng (ben.bob@gmail.com)

* src/bufferlist.C: save opened file list here, do not save slave document
	* src/lyxfunc.C: not here
	* src/session.[nC]: change to single file addition
	* src/lyx_main.C: needed change because of single file addition


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13777 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2006-04-28 14:29:38 +00:00
parent ef442584b7
commit 34770cd68b
5 changed files with 16 additions and 9 deletions

View File

@ -122,6 +122,15 @@ bool BufferList::quitWriteAll()
if (!quitWriteBuffer(*it))
return false;
}
// now, all buffers have been written sucessfully
// save file names to .lyx/session
it = bstore.begin();
for (; it != end; ++it) {
// if master/slave are both open, do not save slave since it
// will be automatically loaded when the master is loaded
if ((*it)->getMasterBuffer() == (*it))
LyX::ref().session().addLastOpenedFile((*it)->fileName());
}
return true;
}

View File

@ -238,9 +238,9 @@ void LyX::priv_exec(int & argc, char * argv[])
if (files.empty() && lyxrc.load_session) {
vector<string> const & lastopened = session_->lastOpenedFiles();
files.insert(files.end(), lastopened.begin(), lastopened.end() );
// clear this list to save a few bytes of RAM
session_->clearLastOpenedFiles();
}
// clear this list to save a few bytes of RAM
session_->clearLastOpenedFiles();
// Execute batch commands if available
if (!batch_command.empty()) {

View File

@ -1011,8 +1011,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
// save cursor Position for opened files to .lyx/session
LyX::ref().session().saveFilePosition(owner->buffer()->fileName(),
boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
// save opened file name to .lyx/session
LyX::ref().session().setLastOpenedFiles( bufferlist.getFileNames());
// save bookmarks to .lyx/session
view()->saveSavedPositions();
}

View File

@ -247,9 +247,9 @@ void Session::clearLastOpenedFiles()
}
void Session::setLastOpenedFiles(vector<string> const & files)
void Session::addLastOpenedFile(string const & file)
{
lastopened = files;
lastopened.push_back(file);
}

View File

@ -82,10 +82,10 @@ public:
*/
void clearLastOpenedFiles();
/** set lastopened file list
@param files filenames of a list of opened files
/** add file to lastopened file list
@param file filename to add
*/
void setLastOpenedFiles(std::vector<std::string> const & files);
void addLastOpenedFile(std::string const & file);
/** load saved cursor position from the fname entry in the filepos map
@param fname file entry for which to load position information