Make new function writeSession(). Now it's no longer entangled with closing the workareas/buffers.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31147 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-08-19 20:06:57 +00:00
parent 5b1e7027ba
commit f9952369ca
3 changed files with 20 additions and 5 deletions

View File

@ -1211,10 +1211,8 @@ void GuiApplication::restoreGuiSession()
// do not add to the lastfile list since these files are restored from
// last session, and should be already there (regular files), or should
// not be added at all (help files).
// Note that we open them in reverse order. This is because we close
// buffers also in reverse order (aesthetically motivated).
for (size_t i = lastopened.size(); i > 0; --i) {
FileName const & file_name = lastopened[i - 1].file_name;
for (size_t i = 0; i < lastopened.size(); ++i) {
FileName const & file_name = lastopened[i].file_name;
if (d->views_.empty() || (!lyxrc.open_buffers_in_tabs
&& current_view_->buffer() != 0)) {
boost::crc_32_type crc;
@ -1224,7 +1222,7 @@ void GuiApplication::restoreGuiSession()
}
current_view_->loadDocument(file_name, false);
if (lastopened[i - 1].active)
if (lastopened[i].active)
active_file = file_name;
}

View File

@ -544,6 +544,8 @@ void GuiView::closeEvent(QCloseEvent * close_event)
LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
closing_ = true;
writeSession();
// it can happen that this event arrives without selecting the view,
// e.g. when clicking the close button on a background window.
setFocus();
@ -1875,6 +1877,19 @@ bool GuiView::closeBuffer()
}
void GuiView::writeSession() const {
GuiWorkArea const * active_wa = currentMainWorkArea();
for (int i = 0; i < d.splitter_->count(); ++i) {
TabWorkArea * twa = d.tabWorkArea(i);
for (int j = 0; j < twa->count(); ++j) {
GuiWorkArea * wa = static_cast<GuiWorkArea *>(twa->widget(j));
Buffer & buf = wa->bufferView().buffer();
theSession().lastOpened().add(buf.fileName(), wa == active_wa);
}
}
}
bool GuiView::closeBufferAll()
{
// First close all workareas. This will make

View File

@ -314,6 +314,8 @@ private:
bool closeBufferAll();
/// closes all workareas
bool closeWorkAreaAll();
/// write all open workareas into the session file
void writeSession() const;
/// is the buffer in this workarea also shown in another tab ?
/// This tab can either be in the same view or in another one.
bool inMultiTabs(GuiWorkArea * wa);