diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index aaf7add117..a4a9df859f 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -27,6 +27,7 @@ #include "support/os.h" #include "support/Package.h" +#include "BufferList.h" #include "BufferView.h" #include "Color.h" #include "debug.h" @@ -43,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -318,6 +320,20 @@ void GuiApplication::unregisterSocketCallback(int fd) socket_callbacks_.erase(fd); } + +void GuiApplication::commitData(QSessionManager & sm) +{ + /// The implementation is required to avoid an application exit + /// when session state save is triggered by session manager. + /// The default implementation sends a close event to all + /// visible top level widgets when session managment allows + /// interaction. + /// We are changing that to write all unsaved buffers... + if (sm.allowsInteraction() && !theBufferList().quitWriteAll()) + sm.cancel(); +} + + //////////////////////////////////////////////////////////////////////// // X11 specific stuff goes here... #ifdef Q_WS_X11 diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index ba0b4c2d72..954c48e064 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -26,6 +26,8 @@ #include #include +class QSessionManager; + namespace lyx { class BufferView; @@ -74,9 +76,10 @@ public: void unregisterSocketCallback(int fd); //@} - /// Methods inherited from \c Application class + /// Methods inherited from \c QApplication class //@{ - virtual bool notify(QObject * receiver, QEvent * event); + bool notify(QObject * receiver, QEvent * event); + void commitData(QSessionManager & sm); //@} ///