Bug 499260 - Automatic shutdown/restart action closes apps without letting them prompt to save changes, potentially causing data loss
Summary: Automatic shutdown/restart action closes apps without letting them prompt to ...
Status: RESOLVED FIXED
Alias: None
Product: Discover
Classification: Applications
Component: Updates (other bugs)
Version First Reported In: 6.2.5
Platform: Fedora RPMs Linux
: HI critical
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 509049 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-01-28 23:23 UTC by EpicTux123
Modified: 2025-10-04 14:45 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.4.6
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description EpicTux123 2025-01-28 23:23:32 UTC
When updating in Discover, there's an option of: "On completion, automatically: [Restart / Shutdown]".

However, using either of those options (I've tested only with Restart, but I assume the same is true for Shutdown) seems to perform a "brute" restart.

When clicking to restart in the application launcher (start menu), Plasma nicely closes all apps before it restarts.
But when using the same option for the automation in Discover it doesn't seem to do that — instead, it seems to do something such as SIGKILL all processes and proceed to restart, without asking them nicely to shut down themselves first.

An example I can give (which just happened to me when using the Restart automation) was that Steam (the gaming app) didn't show "Shutting down Steam..." before it was closed, and Firefox, the next time I started it after rebooting, restored my tabs like if it had recovered from a crash/bad exit (I don't have "Open previous tabs" on start-up enabled).

Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1
Kernel Version: 6.12.10-200.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 1 David Redondo 2025-01-29 12:32:18 UTC
Discover calls org.freedesktop.login1 directly.

Plasma arguably could take a inhibitor to enforce its shutdown process.
Comment 2 Nate Graham 2025-09-23 19:00:22 UTC
*** Bug 509049 has been marked as a duplicate of this bug. ***
Comment 3 Nate Graham 2025-09-23 19:01:33 UTC
Raising priority and severity given the possibility of data loss here.
Comment 4 Justin Zobel 2025-09-24 03:17:24 UTC
Bug or not, I still think a timeout should be added. We can not control every app a user is running on their system, nor should we. We can not guarantee any app would respect a shutdown notice and prompt the user to save their work.
Comment 5 Nate Graham 2025-09-24 18:23:23 UTC
The automatic shutdown/restart feature is optional and not engaged by default. If you turn it on, I think you know what you're getting yourself into: that the system automatically shuts down or restarts after the updates are finished.

If you're actively using the system, the feature doesn't really make sense to use, because it will shut down or restart when you're potentially in the middle of doing something. Even with a timer, all that would do is create stress and panic by making you scramble to close everything before the timer runs out.
Comment 6 EpicTux123 2025-09-24 19:53:43 UTC
I think a better idea would be to simply remove this feature instead of fixing it.

The user is already informed with a very big on-screen text that he needs to restart the computer in order to apply the updates (on Fedora KDE, at least).

Besides that, when going to restart, once again the system shows the "Restart & Install Updates" option too.

(All of this is also true for shutdown.)

So maybe the option being there is an extra that is not really that necessary...?

That's what I think now. Thanks.
Comment 7 Justin Zobel 2025-09-25 00:16:09 UTC
> If you turn it on, I think you know what you're getting yourself into: that the system automatically shuts down or restarts after the updates are finished.

You're talking to a user who forgets things, sometimes within seconds of doing them.
Comment 8 Nate Graham 2025-10-02 17:18:17 UTC
This diff in Discover fixes the issue:


diff --git discover/DiscoverObject.cpp discover/DiscoverObject.cpp
index 5623c21fe..f13aefa8b 100644
--- discover/DiscoverObject.cpp
+++ discover/DiscoverObject.cpp
@@ -670,12 +670,11 @@ void DiscoverObject::promptReboot()
 void DiscoverObject::rebootNow()
 {
     setAboutToReboot();
-    auto method = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.login1"),
-                                                 QStringLiteral("/org/freedesktop/login1"),
-                                                 QStringLiteral("org.freedesktop.login1.Manager"),
-                                                 QStringLiteral("Reboot"));
-    method.setArguments({true /*interactive*/});
-    QDBusConnection::systemBus().asyncCall(method);
+    auto method = QDBusMessage::createMethodCall(QStringLiteral("org.kde.Shutdown"),
+                                                 QStringLiteral("/Shutdown"),
+                                                 QStringLiteral("org.kde.Shutdown"),
+                                                 QStringLiteral("logoutAndReboot"));
+    QDBusConnection::sessionBus().asyncCall(method);
 }
 

The question now is whether porting from org.freedesktop.login1 to org.kde.Shutdown is the right approach, vs plumbing our session teardown code and confirmation prompts through org.freedesktop.login1.
Comment 9 Nate Graham 2025-10-02 17:49:08 UTC
Talked to David E, and porting to org.kde.Shutdown is appropriate here.
Comment 10 Bug Janitor Service 2025-10-02 17:53:24 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/discover/-/merge_requests/1171
Comment 11 Aleix Pol 2025-10-03 20:02:30 UTC
Git commit 025dc056076be0c54a50dc988c18ab2adb439812 by Aleix Pol, on behalf of Nate Graham.
Committed on 03/10/2025 at 18:07.
Pushed by ngraham into branch 'master'.

Use safer org.kde.Shutdown to shut down and restart

Currently we use org.freedesktop.login1, which will not let apps prompt
the user to save changes. This can lead to data loss.

Ideally org.freedesktop.login1 would be plumbed through our session
stuff so apps can prompt, but that's quite a ways away. In the meantime,
use org.kde.Shutdown to resolve the issue.
FIXED-IN: 6.4.6

M  +10   -12   discover/DiscoverObject.cpp

https://invent.kde.org/plasma/discover/-/commit/025dc056076be0c54a50dc988c18ab2adb439812
Comment 12 Nate Graham 2025-10-03 20:04:36 UTC
Git commit 8b3229a431808c05edf6c8c31f7d049927b81a67 by Nate Graham.
Committed on 03/10/2025 at 20:04.
Pushed by ngraham into branch 'Plasma/6.5'.

Use safer org.kde.Shutdown to shut down and restart

Currently we use org.freedesktop.login1, which will not let apps prompt
the user to save changes. This can lead to data loss.

Ideally org.freedesktop.login1 would be plumbed through our session
stuff so apps can prompt, but that's quite a ways away. In the meantime,
use org.kde.Shutdown to resolve the issue.
FIXED-IN: 6.4.6


(cherry picked from commit 025dc056076be0c54a50dc988c18ab2adb439812)

Co-authored-by: Nate Graham <nate@kde.org>

M  +10   -12   discover/DiscoverObject.cpp

https://invent.kde.org/plasma/discover/-/commit/8b3229a431808c05edf6c8c31f7d049927b81a67
Comment 13 Nate Graham 2025-10-03 20:05:53 UTC
Git commit 3c71a1d74d2f0b44cdc91e543b524fccdb770de1 by Nate Graham.
Committed on 03/10/2025 at 20:05.
Pushed by ngraham into branch 'Plasma/6.4'.

Use safer org.kde.Shutdown to shut down and restart

Currently we use org.freedesktop.login1, which will not let apps prompt
the user to save changes. This can lead to data loss.

Ideally org.freedesktop.login1 would be plumbed through our session
stuff so apps can prompt, but that's quite a ways away. In the meantime,
use org.kde.Shutdown to resolve the issue.
FIXED-IN: 6.4.6


(cherry picked from commit 025dc056076be0c54a50dc988c18ab2adb439812)

Co-authored-by: Nate Graham <nate@kde.org>

M  +10   -12   discover/DiscoverObject.cpp

https://invent.kde.org/plasma/discover/-/commit/3c71a1d74d2f0b44cdc91e543b524fccdb770de1