commit 53aa2f15c2e90d28519e3cb6a50af0ea73d6ecec
Author: Juergen Spitzmueller <[email protected]>
Date:   Sat Jul 5 15:48:24 2025 +0200

    Fix loss of last open files after crash (#12374)
    
    This only happened if an additional file had been opened
    during the current session.
---
 src/frontends/qt/GuiView.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 777e825656..91180c79b2 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -3040,8 +3040,13 @@ Buffer * GuiView::loadDocument(FileName const & 
filename, bool tolastfiles)
 
        if (tolastfiles) {
                theSession().lastFiles().add(filename);
+               // refresh last opened list before writing
+               // otherwise we end up with an empty list
+               // when we crash (#12374)
+               theSession().lastOpened().clear();
+               writeSession();
                theSession().writeFile();
-  }
+       }
 
        return newBuffer;
 }
@@ -3776,7 +3781,8 @@ bool GuiView::closeBuffer()
 }
 
 
-void GuiView::writeSession() const {
+void GuiView::writeSession() const
+{
        GuiWorkArea const * active_wa = currentMainWorkArea();
        for (int i = 0; i < d.splitter_->count(); ++i) {
                TabWorkArea * twa = d.tabWorkArea(i);
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to