]> git.lyx.org Git - features.git/commitdiff
Make new function writeSession(). Now it's no longer entangled with closing the worka...
authorVincent van Ravesteijn <vfr@lyx.org>
Wed, 19 Aug 2009 20:06:57 +0000 (20:06 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Wed, 19 Aug 2009 20:06:57 +0000 (20:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31147 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h

index 01672acfe60997153bc36583ece93c30d7c3dbcb..dfb06a39c0b97b2308845f04b0b4433dd6b25c5d 100644 (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;
        }
 
index 6821bbdd59acdac74d885c33be45b34826f7606c..762af8bcc0d4f79659b0a3262065d1e874304955 100644 (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
index 5661df26565d6644ab5e4ebc941f3f96ceeafb18..21ebdf81b854cf247ea64be707530bf8e655cee6 100644 (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);