Bug 142176 - No prompt during logout/restart/shutdown when there's unsaved documents
Summary: No prompt during logout/restart/shutdown when there's unsaved documents
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.4.7.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium enhancement
Assignee: Caolán McNamara
URL:
Whiteboard: target:7.6.0
Keywords: dataLoss
: 155765 (view as bug list)
Depends on:
Blocks: Desktop-Integration Exit
  Show dependency treegraph
 
Reported: 2021-05-09 00:14 UTC by Eren Seymen
Modified: 2023-08-16 14:48 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
screenshot (2.16 MB, image/png)
2023-05-09 18:53 UTC, Caolán McNamara
Details
strace when trying to logout but no warning (GNOME 3.36.8) (1.04 MB, application/x-bzip)
2023-05-13 09:39 UTC, Stéphane Guillou (stragu)
Details
strace: no warning -> restart normal mode -> warning (GNOME 3.36.8) (4.26 MB, application/x-bzip)
2023-05-13 09:54 UTC, Stéphane Guillou (stragu)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eren Seymen 2021-05-09 00:14:47 UTC
Description:
Solution:

Gnome folks say applications should subscribe to Gnome session manager's D-Bus interface to be able to receive "session close" signal and then act accordingly.
https://discourse.gnome.org/t/can-ubuntu-prompt-me-to-save-unsaved-documents-during-logout-restart-shutdown/6393

For GTK applications, if "GtkApplication" is used, this is automatic. As Gnome folks say, there's no generic session management across DEs, and other DEs have their own implementations for session managing. I'm guessing, using "GtkApplication" should solve the issue for GTK-based DEs. KDE (and other DEs) needs separate coverage here. (QT-based DEs may have a common solution for this. Don't know.)

Steps to Reproduce:
LibreOffice 6.4.7.2
OS: Ubuntu 20.04 Gnome 3.36.8


Setup:
* Autosave is set to 10 minutes (default)
https://i.imgur.com/7CpvjQ7.png

Steps:
1) Open Writer and write something
2) Logout from Gnome session
>> There's no prompt that there are unsaved changes. See Gedit's prompt: https://i.imgur.com/Jpv0O94.png
3) Login to Gnome
4) Open Writer
>> Writer gives the option to recover file
5) Accept Writer's recovering option

Actual Results:
>> File is empty. Data loss. *FAIL*

Expected Results:
Expected: No data loss.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
I think the solution can be implemented in 2 ways.

WAY1:
1) Open Writer and write something
2) Logout from Gnome session
>> LibreOffice gets "session close" signal from DE.
>> LibreOffice prompts the user about unsaved changes as Gedit can do.
3) User handles the rest.
>> No data loss. *SUCCESS*

WAY2:
1) Open Writer and write something
2) Logout from Gnome session
>> LibreOffice gets "session close" signal from DE. LibreOffice saves session. (autosave)
3) Login to Gnome
4) Open Writer
>> Writer gives the option to recover file
5) Accept Writer's recovering option
>> File is recovered. *SUCCESS*
Comment 1 Stéphane Guillou (stragu) 2023-05-05 23:01:45 UTC
Thanks Eren. Reproduced with Ubuntu 20.04, GNOME 3.36.8 and a recent master build:

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: b10417eb1e5a4a6959e7fc1cdd9819e5b09d39a4
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Logging out does not prompt that LO might have unsaved work. Other apps like gedit do.

Caolán, is this something you'd be interested in?
Comment 2 Commit Notification 2023-05-09 09:20:22 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4a8a24be5a378308680a0b6e2e246d5d9df414c4

Related: tdf#142176 document what the other inhibit options are

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 3 Commit Notification 2023-05-09 09:21:24 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/796fb57d7b2e2ea05795dc49c4438c25adc26fd4

Related: tdf#142176 rearrange screensaver inhibiter to be more generic

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Commit Notification 2023-05-09 18:42:58 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/c04d0570b6c8c78e35c2c9b58bf37bb1218021f5

Resolves: tdf#142176 under GNOME inhibit logout if there are modified docs

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Caolán McNamara 2023-05-09 18:53:53 UTC
Created attachment 187173 [details]
screenshot

Under gnome we should get the same behavior as gedit now, the prompt that there are unsaved docs as shown in this screenshot
Comment 6 Stéphane Guillou (stragu) 2023-05-11 15:37:57 UTC
That didn't fix it for me on Ubuntu 20.04 with GNOME 3.36.8 with:

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 88bd66d258de5fee3d35aba80c61fec49eb2a969
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Some difference in GNOME versions?
Comment 7 Caolán McNamara 2023-05-12 08:20:03 UTC
With GNOME 43.4 on Fedora 38 I get the above case in the screenshot. If its not working elsewhere then it would need someone to debug the newly added code to see if its getting used at all.
Comment 8 Stéphane Guillou (stragu) 2023-05-13 09:39:09 UTC
Created attachment 187242 [details]
strace when trying to logout but no warning (GNOME 3.36.8)

(In reply to Caolán McNamara from comment #7)
> With GNOME 43.4 on Fedora 38 I get the above case in the screenshot. If its
> not working elsewhere then it would need someone to debug the newly added
> code to see if its getting used at all.

Here's an strace for when I try to close a Writer document, with no warning in the logout dialog.

I noticed something that can maybe give a hint:

- If I start Writer, add unsaved edits, then try to log out: no warning
- If I start Writer, Help > Restart in safe mode > Restart in normal mode, add unsaved edits, then try to log out: warning in the logout confirmation (with a small delay)

So the warning is only triggered after an LO session restart for some reason. I can do a screen capture of that second case if that helps.
Comment 9 Stéphane Guillou (stragu) 2023-05-13 09:54:09 UTC
Created attachment 187243 [details]
strace: no warning -> restart normal mode -> warning (GNOME 3.36.8)

Another strace in which I:
- start Writer, edit document, try to log out without saving: no warning from GNOME;
- restart LO in normal mode, edit document, try to log out without saving: warning from GNOME after small delay.
Comment 10 Julien Nabet 2023-06-10 11:34:00 UTC
*** Bug 155765 has been marked as a duplicate of this bug. ***