Qt applications close when selecting "shut down" in Gnome 3
-
Looks like if Qt application does not implement a session management then Qt will force such app to quit on any request from Session Manager.
To avoid it the application must implement something like this "example":http://qt-project.org/doc/qt-5/qsessionmanager.html#allowsInteractionGnome3 sends a SM "SaveYourself" request before showing a "Shutdown" or "Logout" dialog and it kills Qt apps without session management.
I guess neither LyX nor skype implement a session management as it is suggested in "Getting Session Management to Work with Qt":http://qt-project.org/doc/qt-5/session.html#getting-session-management-to-work-with-qt
-
Thanks, it looks like we're getting somewhere !
I found the following code in LyX's source :
@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 close all wiew one by one.
/// FIXME: verify if the default implementation is enough now.
#ifdef QT_NO_SESSIONMANAGER
#ifndef _MSC_VER
#warning Qt is compiled without session manager
#else
#pragma message("warning: Qt is compiled without session manager")
#endif
(void) sm;
#else
if (sm.allowsInteraction() && !closeAllViews())
sm.cancel();
#endif
}
@If I get it right, this seems to be a bit too straightforward...
I'm not sure if I can rewrite this myself, but I can certainly try to get the attention of the LyX developers. -
Sure you can, it's just a slot you need to have somewhere and make the connection, no need to subclass QApplication or QGuiApplication
-
OK, you encouraged me to take a closer look, but I don't understand the rationale.
I don't want direct user interaction, which is what the "QSessionManager::allowsInteraction()" seems to test for, just it to handle GNOME signals correctly.Anyway, I started putting the slot in the lyx code though, but I'm not used to C++, so I'm having a hard time figuring out what variables should be declared, inherited ... in short, I don't know what part of the example code is universal and what part is application-specific. It's not just a matter of copy-and-paste ...
-
[quote author="Jos_k" date="1411368631"]
I found the following code in LyX's source :
@void GuiApplication::commitData(QSessionManager & sm)
{
if (sm.allowsInteraction() && !closeAllViews())
sm.cancel();
}
@
[/quote]This is exactly what Qt doc recommends to do.
A connect from qApp should be somewhere in the code.
@
connect(qApp, SIGNAL(commitDataRequest(QSessionManager)), this, SLOT(commitData(QSessionManager)));
@
where this is a pointer to GuiApplication.But it will not help to avoid closing an application on "Shutdown" or "Logout" dialog if all data is already saved.
Since Gnome3 sends these requests before showing a dialog Qt app with all data saved will quit without any questions. -
I didn't find the "connect to slot" line in the code. I might try to find how to construct a pointer to a void function in c++, if I have some time left today.
As you seem to confirm, it's not only about allowing user interaction, but also about correctly handling GNOME's signals before interaction.
But if a prompt allowing me to save unsaved changes would show up when the dialog appears, this would already help a lot.For the moment, I work around this problem by suspending the computer directly by pushing the power button ; the LyX window survives.
-
Did you also brought that to the Gnome team ?
-
"Gnome mailing lists":https://mail.gnome.org/mailman/listinfo
"IRC Channel":https://wiki.gnome.org/Community/GettingInTouch/IRC -
I'd go for gnome-shell, AFAIK dgm is the part that handle drawing not session management
-
Hi,
I'm experiencing the same issues as described in this thread. Additionally, I'd like to mention that for some applications (for instance Qt Creator), it goes as far as shutting down the computer without waiting for the user to choose an option in the shutdown dialog. I posted "another thread":https://qt-project.org/forums/viewthread/53243 before finding this one.
Are there any developments about this since September?
-
Hi,
I'm experiencing the same issues as described in this thread. Additionally, I'd like to mention that for some applications (for instance Qt Creator), it goes as far as shutting down the computer without waiting for the user to choose an option in the shutdown dialog. I posted "another thread":https://qt-project.org/forums/viewthread/53243 before finding this one.
Are there any developments about this since September?