From 8fd3e3ecbc002c40e5ef29b9edf5d410ec52a572 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 27 Aug 2007 07:13:05 +0000 Subject: [PATCH] New 'Save all on shutdown or cancel' feature from Stephan Witt (Fix bug 1656). * GuiApplication::commitData(): implement. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19825 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiApplication.cpp | 16 ++++++++++++++++ src/frontends/qt4/GuiApplication.h | 7 +++++-- status.15x | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 18da529ddc..4b3ed3e9c8 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" @@ -42,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -313,6 +315,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); //@} /// diff --git a/status.15x b/status.15x index 01cfd45cab..60d1ad4bcc 100644 --- a/status.15x +++ b/status.15x @@ -50,6 +50,8 @@ What's new - Add paragraph-params LFUN, used for updating paragraph parameters (Bug 2714). +- Add "Save all on log-out or cancel" feature (Bug 1656). + ** Bug fixes: ************* @@ -94,6 +96,8 @@ What's new - Reset current cursor font when going to a bookmark. +- Fix crash when login out from within Gnome desktop (Bug 1656). + * DOCUMENTATION