Hi Richard,

you moved the target milestone of bug 1656 to 1.5.x. Now I had the time and energy to check my proposal to fix the bug again. I modified the code to fit the new 1.5.x code base. My tests with OpenSuSE 10.2 and Qt 4.1.2 went well. The program isn't exiting prematurely anymore and in case of unsaved changes the user is asked for proper action just like on quit of LyX.

The idea was: the default session save action of Qt is to send an close event to all windows (in method commitData()). I replaced it by an call to theBufferList().quitWriteAll(). This didn't work with older Qt versions apparently. Now I have no problem with my current Qt 4.1.2 anymore.

The resulting patch is attached and in bugzilla too.

Regards,

Stephan

-------- Original-Nachricht --------
Betreff: [Bug 1656] command "gnome-session-save" kills lyx!
Datum: Mon, 20 Aug 2007 13:38:44 +0200
Von: [EMAIL PROTECTED]
An: [EMAIL PROTECTED]

http://bugzilla.lyx.org/show_bug.cgi?id=1656

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #728 is|0                           |1
           obsolete|                            |



------- Additional Comments From [EMAIL PROTECTED] 2007-08-20 13:38 -------
Created an attachment (id=2110)
 --> (http://bugzilla.lyx.org/attachment.cgi?id=2110&action=view)
Updated patch for bad exit on gnome-session-save

I've updated my patch for 1.5.X and tested it with activated (comments removed)
code.
The patch works with OpenSuSE 10.2 and Qt 4.1.2. Cannot test others
environments.



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
Index: src/frontends/qt4/GuiApplication.cpp
===================================================================
--- src/frontends/qt4/GuiApplication.cpp	(Revision 19655)
+++ src/frontends/qt4/GuiApplication.cpp	(Arbeitskopie)
@@ -28,6 +28,7 @@
 #include "support/Package.h"
 
 #include "BufferView.h"
+#include "BufferList.h"
 #include "Color.h"
 #include "debug.h"
 #include "FuncRequest.h"
@@ -316,6 +317,22 @@
 ////////////////////////////////////////////////////////////////////////
 // X11 specific stuff goes here...
 #ifdef Q_WS_X11
+
+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 changeing that to write all unsaved buffers...
+	if ( sm.allowsInteraction() ) {
+	 	if ( !theBufferList().quitWriteAll() ) {
+	 		sm.cancel();
+	 	}
+	}
+}
+
 bool GuiApplication::x11EventFilter(XEvent * xev)
 {
 	if (!currentView())
Index: src/frontends/qt4/GuiApplication.h
===================================================================
--- src/frontends/qt4/GuiApplication.h	(Revision 19655)
+++ src/frontends/qt4/GuiApplication.h	(Arbeitskopie)
@@ -25,6 +25,7 @@
 
 #include <QApplication>
 #include <QTranslator>
+#include <QSessionManager>
 
 namespace lyx {
 
@@ -106,6 +107,7 @@
 	std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
 
 #ifdef Q_WS_X11
+	void commitData(QSessionManager & sm);
 public:
 	bool x11EventFilter (XEvent * ev);
 #endif

Reply via email to