[LyX/master] Another take on exit-crash on macOS Tahoe.

Pavel Sanda <[email protected]> Mon, 22 Jun 2026 21:21:40 +0000
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit be0260ba78ec533b4049530dd78ffca582030315
Author: Pavel Sanda <[email protected]>
Date:   Mon Jun 22 23:17:47 2026 +0200

    Another take on exit-crash on macOS Tahoe.
    
    Reverts 8ed3745da456e, which fixes the crash but introduces
    new regression (session information not stored on exit).
    
    Claude's theory why the original crash occurs:
    close() is invoked synchronously from inside a QAction slot - Qt has to
    tear down NSWindow / NSMenu state while the QAction-triggered invocation is
    still on the stack. macOS Tahoe / Qt 6 might not tolerate that anymore.
    QTimer::singleShot will defer to the next event-loop iteration.
    
    https://www.mail-archive.com/[email protected]/msg226398.html
    
    Assisted-by: Claude Opus 4.7
---
 src/frontends/qt/GuiApplication.cpp | 17 +++++------------
 src/frontends/qt/GuiView.h          |  4 ++--
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
index cb68a0ba6d..532388a888 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -103,9 +103,6 @@
 #include <QMenuBar>
 #include <QMimeData>
 #include <QObject>
-#if defined(Q_OS_MACOS) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
-#include <QOperatingSystemVersion>
-#endif
 #include <QPainter>
 #include <QPixmap>
 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
@@ -1794,16 +1791,12 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 		break;
 
 	case LFUN_LYX_QUIT:
-		if (current_view_) {
+		if (current_view_)
 			current_view_->message(from_utf8(N_("Exiting.")));
-			if (!current_view_->closeBufferAll()) {
-				current_view_->message(from_utf8(N_("Cancelled")));
-				break;
-			}
-		}
-		// quitting is triggered by the gui code
-		// (leaving the event loop).
-		QApplication::quit();
+		QTimer::singleShot(0, this, [this]() {
+			if (closeAllViews())
+				quit();
+		});
 		break;
 
 	case LFUN_SCREEN_FONT_UPDATE: {
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 727cd4ccec..a82447d831 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -165,8 +165,6 @@ public:
 	bool closeWorkArea(GuiWorkArea * wa);
 	/// closes the buffer
 	bool closeBuffer(Buffer & buf);
-	/// Close all document buffers.
-	bool closeBufferAll();
 
 	///
 	void openDocuments(std::string const & filename, int origin);
@@ -328,6 +326,8 @@ private:
 	void openChildDocument(std::string const & filename);
 	/// Close current document buffer.
 	bool closeBuffer();
+	/// Close all document buffers.
+	bool closeBufferAll();
 	///
 	TabWorkArea * addTabWorkArea();
 
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs