Bug 469690 - Kate and Kwrite - Close Document warning dialog returns after completion.
Summary: Kate and Kwrite - Close Document warning dialog returns after completion.
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (show other bugs)
Version: 23.04.0
Platform: Manjaro Linux
: NOR minor
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 477173 482545 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-05-13 08:19 UTC by Ben Guy-Williams
Modified: 2024-03-06 18:28 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Kate-Kwrite dialog in question (34.38 KB, image/png)
2023-05-13 08:22 UTC, Ben Guy-Williams
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Guy-Williams 2023-05-13 08:19:14 UTC
SUMMARY
***
Warning dialogue recurs after cancelling
***


STEPS TO REPRODUCE
1.  Create a file 'Kate' or 'Kwrite' and enter text 'this is a text'. 
2.  Save the file.
3.  Type some more.
4. Quit the application
5. Click Cancel ONE TIME.

OBSERVED RESULT
Dialog returns, very slightly altered in shape - but with identical text and options.

EXPECTED RESULT
After clicking Cancel, the dialog should not re-appear.

SOFTWARE/OS VERSIONS
Operating System: Manjaro Linux 
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9
Kernel Version: 6.3.0-1-MANJARO (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 5600G with Radeon Graphics
Memory: 15.0 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Product Name: B550M Steel Legend
Comment 1 Ben Guy-Williams 2023-05-13 08:22:27 UTC
Created attachment 158903 [details]
Kate-Kwrite dialog in question

file:///home/ben/Desktop/Kate-Kwrite-Bug.png
Comment 2 Nate Graham 2023-08-26 21:20:14 UTC
Can reproduce.
Comment 3 Nate Graham 2023-08-31 23:08:56 UTC
Happens for Ctrl+Q or when clicking the window's close button, but not when closing just one document with Ctrl+W or its tab's close button.
Comment 4 Nate Graham 2023-09-01 01:41:41 UTC
Tried to bisect but was unable to succeed because at a certain point the kate repo stopped compiling. Did a bit of debugging in KateApp::shutdownKate() but got lost after a while. My current theory is that the quit signal is being handled by something else and blocking the first quit, but that's just an educated guess at this point.

Probably need the Kate developers to take over from here.
Comment 5 Christoph Cullmann 2023-09-02 14:16:23 UTC
Yeah, that is a bad thing but I missed to track back how or why it is broken, too :(
Comment 6 Waqar Ahmed 2023-09-04 05:53:07 UTC
Pasting my message from a weeks ago in kate chat room about this;

re the double dialog issue on Ctrl+Q. It is handled by KateApp::shutdownKate, The first dialog is a result of:

    if (!win->queryClose_internal()) {
        return;
    }
and the second:

QApplication::quit();

...
    #8 0x7ff30f88fe9c in KateMainWindow::queryClose() kde/src/utilities/kate/apps/lib/katemainwindow.cpp:687:9
    #9 0x7ff30d9ba6de in KMainWindow::closeEvent(QCloseEvent*) kde/src/frameworks/kxmlgui/src/kmainwindow.cpp:538:9
...
    #31 0x7ff30f794c4c in KateApp::shutdownKate(KateMainWindow*)kde/src/utilities/kate/apps/lib/kateapp.cpp:486:5

I think the behaviour changed somewhere in Qt6
Comment 7 Kai Uwe Broulik 2023-09-19 21:17:25 UTC
Indeed, it did change, sometimes RTFM helps :-) https://invent.kde.org/utilities/kate/-/merge_requests/1305
Comment 8 Kai Uwe Broulik 2023-09-19 21:19:03 UTC
Though this bug says Qt 5.15. So something else is broken, too?
Comment 9 Christoph Cullmann 2023-09-20 09:04:56 UTC
Git commit 1949852afa14f4c479ca96e85cec3661d454efad by Christoph Cullmann, on behalf of Kai Uwe Broulik.
Committed on 20/09/2023 at 10:49.
Pushed by cullmann into branch 'master'.

Explicitly call QCoreApplication::exit()

> In Qt 5, QCoreApplication::quit() was equivalent to calling QCoreApplication::exit().
> This just exited the main event loop.
> In Qt 6, the method will instead try to close all top-level windows by posting a close event.
> The windows are free to cancel the shutdown process by ignoring the event.
> Call QCoreApplication::exit() to keep the non-conditional behavior.

Kate already does its own cleanup and close handling when the event loop
exits, now leading to double prompts when Qt sends a close event and then
Kate tries to close them. Instead, just call `exit()`.

M  +3    -3    apps/kate/katewaiter.cpp
M  +5    -1    apps/lib/kateapp.cpp

https://invent.kde.org/utilities/kate/-/commit/1949852afa14f4c479ca96e85cec3661d454efad
Comment 10 Christoph Cullmann 2023-09-20 09:09:12 UTC
Git commit a03c5190fb1b2202d684674b7ed32f6a05388042 by Christoph Cullmann, on behalf of Kai Uwe Broulik.
Committed on 20/09/2023 at 11:09.
Pushed by cullmann into branch 'release/23.08'.

Explicitly call QCoreApplication::exit()

> In Qt 5, QCoreApplication::quit() was equivalent to calling QCoreApplication::exit().
> This just exited the main event loop.
> In Qt 6, the method will instead try to close all top-level windows by posting a close event.
> The windows are free to cancel the shutdown process by ignoring the event.
> Call QCoreApplication::exit() to keep the non-conditional behavior.

Kate already does its own cleanup and close handling when the event loop
exits, now leading to double prompts when Qt sends a close event and then
Kate tries to close them. Instead, just call `exit()`.


(cherry picked from commit 1949852afa14f4c479ca96e85cec3661d454efad)

M  +3    -3    apps/kate/katewaiter.cpp
M  +5    -1    apps/lib/kateapp.cpp

https://invent.kde.org/utilities/kate/-/commit/a03c5190fb1b2202d684674b7ed32f6a05388042
Comment 11 Christoph Cullmann 2023-09-20 09:09:58 UTC
The cherry picked comment doesn't match, but it might fix the issue.
Comment 12 popov895 2023-10-30 17:58:37 UTC
Should it already be fixed in 23.08.2? If so, it's still not fixed.
Comment 13 popov895 2023-11-26 09:34:00 UTC
Looks like the cause of this bug is https://invent.kde.org/utilities/kate/-/commit/99b98212e4d00ce75015e535ea5ea3cc4e227366. Can you look?
Comment 14 Bug Janitor Service 2023-11-27 10:29:23 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1363
Comment 15 popov895 2023-11-27 13:17:04 UTC
*** Bug 477173 has been marked as a duplicate of this bug. ***
Comment 16 Christoph Cullmann 2023-11-27 18:01:44 UTC
Git commit 4a9110d662cc3d2cdd90561d9803a7655a1a5721 by Christoph Cullmann, on behalf of Eugene Popov.
Committed on 27/11/2023 at 18:57.
Pushed by cullmann into branch 'master'.

Avoid asking the user twice for required actions when closing a window

M  +2    -3    apps/lib/katemainwindow.cpp

https://invent.kde.org/utilities/kate/-/commit/4a9110d662cc3d2cdd90561d9803a7655a1a5721
Comment 17 Waqar Ahmed 2024-03-06 18:28:37 UTC
*** Bug 482545 has been marked as a duplicate of this bug. ***