Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-10-13 17:37:22 +0300
committerHannah von Reth <vonreth@kde.org>2021-10-13 18:15:49 +0300
commitb1e17395c057ca2336bbbdf50f39c00fbf33620f (patch)
tree9642938ce4e5881ca0d38b359a722154a0b8a130
parent9b5a99f23a912c102fb8093112d58e19c536ec5a (diff)
Fix application shutdown during Windows logout
-rw-r--r--changelog/unreleased/89796
-rw-r--r--src/gui/settingsdialog.cpp16
-rw-r--r--src/gui/settingsdialog.h4
3 files changed, 26 insertions, 0 deletions
diff --git a/changelog/unreleased/8979 b/changelog/unreleased/8979
new file mode 100644
index 000000000..8846fe3e6
--- /dev/null
+++ b/changelog/unreleased/8979
@@ -0,0 +1,6 @@
+Bugfix: Properly handle Windows log off
+
+We worked around a Qt bug which prevented the client from properly shutdown
+on Windows logout or during the client update.
+
+https://github.com/owncloud/client/issues/8979
diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp
index 01ebffc9b..3aad0f75c 100644
--- a/src/gui/settingsdialog.cpp
+++ b/src/gui/settingsdialog.cpp
@@ -326,6 +326,22 @@ void SettingsDialog::setVisible(bool visible)
QMainWindow::setVisible(visible);
}
+#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+
+bool SettingsDialog::nativeEvent(const QByteArray &eventType, void *message, long *result)
+{
+ auto msg = reinterpret_cast<MSG *>(message);
+ // https://github.com/owncloud/client/issues/8979
+ // Qt5 has a bug that Windows already get closed on WM_QUERYENDSESSION
+ // so they never receive WM_ENDSESSION
+ // Capture the event and go down in style
+ if (msg->message == WM_QUERYENDSESSION || msg->message == WM_ENDSESSION) {
+ QTimer::singleShot(0, ocApp(), Application::quit);
+ }
+ return false;
+}
+#endif
+
void SettingsDialog::slotSwitchPage(QAction *action)
{
_ui->stack->setCurrentWidget(_actionGroupWidgets.value(action));
diff --git a/src/gui/settingsdialog.h b/src/gui/settingsdialog.h
index c96e559e0..f84734fdd 100644
--- a/src/gui/settingsdialog.h
+++ b/src/gui/settingsdialog.h
@@ -71,6 +71,10 @@ protected:
void changeEvent(QEvent *) override;
void setVisible(bool visible) override;
+#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
+#endif
+
private slots:
void accountAdded(AccountState *);
void accountRemoved(AccountState *);