// 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;
}
current_view_->loadDocument(file_name, false);
- if (lastopened[i - 1].active)
+ if (lastopened[i].active)
active_file = file_name;
}
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();
}
+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
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);