Remove "fallback session management"
With the Qt6 compatibility break, it can finally be removed. Closing windows (which might quit the application with quitOnLastWindowClosed() true, the default) acted contrary to the documentation of the commitDataRequest() signal, which could have been a hint. This removes the workaround API from the fix for QTBUG-49667 and also removes the problematic feature that it worked around. Change-Id: I672be58864ef062df7fb7f2a81658b92c4feedd2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
98f41552e4
commit
7f878c6217
@ -70,7 +70,6 @@ MainWindow::MainWindow()
|
||||
this, &MainWindow::documentWasModified);
|
||||
|
||||
#ifndef QT_NO_SESSIONMANAGER
|
||||
QGuiApplication::setFallbackSessionManagementEnabled(false);
|
||||
connect(qApp, &QGuiApplication::commitDataRequest,
|
||||
this, &MainWindow::commitData);
|
||||
#endif
|
||||
|
@ -80,7 +80,6 @@ int main(int argc, char *argv[])
|
||||
MyMainWidget::MyMainWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QGuiApplication::setFallbackSessionManagementEnabled(false);
|
||||
connect(qApp, &QGuiApplication::commitDataRequest,
|
||||
this, &MyMainWidget::commitData);
|
||||
}
|
||||
|
@ -162,10 +162,6 @@ QPlatformTheme *QGuiApplicationPrivate::platform_theme = nullptr;
|
||||
|
||||
QList<QObject *> QGuiApplicationPrivate::generic_plugin_list;
|
||||
|
||||
#ifndef QT_NO_SESSIONMANAGER
|
||||
bool QGuiApplicationPrivate::is_fallback_session_management_enabled = true;
|
||||
#endif
|
||||
|
||||
enum ApplicationResourceFlags
|
||||
{
|
||||
ApplicationFontExplicitlySet = 0x2
|
||||
@ -721,9 +717,6 @@ QGuiApplication::~QGuiApplication()
|
||||
QGuiApplicationPrivate::highDpiScalingUpdated = false;
|
||||
QGuiApplicationPrivate::currentDragWindow = nullptr;
|
||||
QGuiApplicationPrivate::tabletDevicePoints.clear();
|
||||
#ifndef QT_NO_SESSIONMANAGER
|
||||
QGuiApplicationPrivate::is_fallback_session_management_enabled = true;
|
||||
#endif
|
||||
QGuiApplicationPrivate::mousePressTime = 0;
|
||||
QGuiApplicationPrivate::mousePressX = QGuiApplicationPrivate::mousePressY = 0;
|
||||
}
|
||||
@ -3649,27 +3642,6 @@ bool QGuiApplicationPrivate::shouldQuitInternal(const QWindowList &processedWind
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QGuiApplicationPrivate::tryCloseAllWindows()
|
||||
{
|
||||
return tryCloseRemainingWindows(QWindowList());
|
||||
}
|
||||
|
||||
bool QGuiApplicationPrivate::tryCloseRemainingWindows(QWindowList processedWindows)
|
||||
{
|
||||
QWindowList list = QGuiApplication::topLevelWindows();
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
QWindow *w = list.at(i);
|
||||
if (w->isVisible() && !processedWindows.contains(w)) {
|
||||
if (!w->close())
|
||||
return false;
|
||||
processedWindows.append(w);
|
||||
list = QGuiApplication::topLevelWindows();
|
||||
i = -1;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QGuiApplicationPrivate::processApplicationTermination(QWindowSystemInterfacePrivate::WindowSystemEvent *windowSystemEvent)
|
||||
{
|
||||
QEvent event(QEvent::Quit);
|
||||
@ -3771,57 +3743,6 @@ void QGuiApplicationPrivate::setApplicationState(Qt::ApplicationState state, boo
|
||||
emit qApp->applicationStateChanged(applicationState);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SESSIONMANAGER
|
||||
// ### Qt6: consider removing the feature or making it less intrusive
|
||||
/*!
|
||||
\since 5.6
|
||||
|
||||
Returns whether QGuiApplication will use fallback session management.
|
||||
|
||||
The default is \c true.
|
||||
|
||||
If this is \c true and the session manager allows user interaction,
|
||||
QGuiApplication will try to close toplevel windows after
|
||||
commitDataRequest() has been emitted. If a window cannot be closed, session
|
||||
shutdown will be canceled and the application will keep running.
|
||||
|
||||
Fallback session management only benefits applications that have an
|
||||
"are you sure you want to close this window?" feature or other logic that
|
||||
prevents closing a toplevel window depending on certain conditions, and
|
||||
that do nothing to explicitly implement session management. In applications
|
||||
that \e do implement session management using the proper session management
|
||||
API, fallback session management interferes and may break session
|
||||
management logic.
|
||||
|
||||
\warning If all windows \e are closed due to fallback session management
|
||||
and quitOnLastWindowClosed() is \c true, the application will quit before
|
||||
it is explicitly instructed to quit through the platform's session
|
||||
management protocol. That violation of protocol may prevent the platform
|
||||
session manager from saving application state.
|
||||
|
||||
\sa setFallbackSessionManagementEnabled(),
|
||||
QSessionManager::allowsInteraction(), saveStateRequest(),
|
||||
commitDataRequest(), {Session Management}
|
||||
*/
|
||||
bool QGuiApplication::isFallbackSessionManagementEnabled()
|
||||
{
|
||||
return QGuiApplicationPrivate::is_fallback_session_management_enabled;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.6
|
||||
|
||||
Sets whether QGuiApplication will use fallback session management to
|
||||
\a enabled.
|
||||
|
||||
\sa isFallbackSessionManagementEnabled()
|
||||
*/
|
||||
void QGuiApplication::setFallbackSessionManagementEnabled(bool enabled)
|
||||
{
|
||||
QGuiApplicationPrivate::is_fallback_session_management_enabled = enabled;
|
||||
}
|
||||
#endif // QT_NO_SESSIONMANAGER
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
\fn void QGuiApplication::commitDataRequest(QSessionManager &manager)
|
||||
@ -3846,8 +3767,7 @@ void QGuiApplication::setFallbackSessionManagementEnabled(bool enabled)
|
||||
|
||||
\note You should use Qt::DirectConnection when connecting to this signal.
|
||||
|
||||
\sa setFallbackSessionManagementEnabled(), isSessionRestored(),
|
||||
sessionId(), saveStateRequest(), {Session Management}
|
||||
\sa isSessionRestored(), sessionId(), saveStateRequest(), {Session Management}
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -3955,13 +3875,7 @@ void QGuiApplicationPrivate::commitData()
|
||||
{
|
||||
Q_Q(QGuiApplication);
|
||||
is_saving_session = true;
|
||||
|
||||
emit q->commitDataRequest(*session_manager);
|
||||
if (is_fallback_session_management_enabled && session_manager->allowsInteraction()
|
||||
&& !tryCloseAllWindows()) {
|
||||
session_manager->cancel();
|
||||
}
|
||||
|
||||
is_saving_session = false;
|
||||
}
|
||||
|
||||
|
@ -168,9 +168,6 @@ public:
|
||||
QString sessionId() const;
|
||||
QString sessionKey() const;
|
||||
bool isSavingSession() const;
|
||||
|
||||
static bool isFallbackSessionManagementEnabled();
|
||||
static void setFallbackSessionManagementEnabled(bool);
|
||||
#endif
|
||||
|
||||
static void sync();
|
||||
|
@ -107,7 +107,6 @@ public:
|
||||
virtual bool shouldQuit() override;
|
||||
|
||||
bool shouldQuitInternal(const QWindowList &processedWindows);
|
||||
virtual bool tryCloseAllWindows();
|
||||
|
||||
static void captureGlobalModifierState(QEvent *e);
|
||||
static Qt::KeyboardModifiers modifier_buttons;
|
||||
@ -279,7 +278,6 @@ public:
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_SESSIONMANAGER
|
||||
static bool is_fallback_session_management_enabled;
|
||||
QSessionManager *session_manager;
|
||||
bool is_session_restored;
|
||||
bool is_saving_session;
|
||||
@ -341,7 +339,6 @@ protected:
|
||||
virtual QPalette basePalette() const;
|
||||
virtual void handlePaletteChanged(const char *className = nullptr);
|
||||
|
||||
bool tryCloseRemainingWindows(QWindowList processedWindows);
|
||||
#if QT_CONFIG(draganddrop)
|
||||
virtual void notifyDragStarted(const QDrag *);
|
||||
#endif // QT_CONFIG(draganddrop)
|
||||
|
@ -76,9 +76,6 @@ QT_BEGIN_NAMESPACE
|
||||
QSessionManager object as argument. The session manager can only be
|
||||
accessed in slots invoked by these signals.
|
||||
|
||||
\warning If you use QSessionManager, you should disable fallback session
|
||||
management: QGuiApplication::setFallbackSessionManagementEnabled().
|
||||
|
||||
No user interaction is possible \e unless the application gets explicit
|
||||
permission from the session manager. You ask for permission by calling
|
||||
allowsInteraction() or, if it is really urgent, allowsErrorInteraction().
|
||||
|
@ -1602,13 +1602,6 @@ retry:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QApplicationPrivate::tryCloseAllWindows()
|
||||
{
|
||||
QWindowList processedWindows;
|
||||
return QApplicationPrivate::tryCloseAllWidgetWindows(&processedWindows)
|
||||
&& QGuiApplicationPrivate::tryCloseRemainingWindows(processedWindows);
|
||||
}
|
||||
|
||||
/*!
|
||||
Closes all top-level windows.
|
||||
|
||||
|
@ -107,7 +107,6 @@ public:
|
||||
virtual void notifyActiveWindowChange(QWindow *) override;
|
||||
|
||||
virtual bool shouldQuit() override;
|
||||
bool tryCloseAllWindows() override;
|
||||
|
||||
static bool autoSipEnabled;
|
||||
static QString desktopStyleKey();
|
||||
|
Loading…
Reference in New Issue
Block a user