Bug 478734

Summary: Main window is not closable after first close to tray
Product: [Frameworks and Libraries] frameworks-kstatusnotifieritem Reporter: Andrew Shark <ashark>
Component: generalAssignee: Alexander Lohnau <alexander.lohnau>
Status: RESOLVED UPSTREAM    
Severity: normal CC: mike, nicolas.fella, stefano.crocco, vinca.ostravsky
Priority: NOR Keywords: qt6
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=443129
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Andrew Shark 2023-12-19 17:11:40 UTC
It is impossible to close the KMail window second time.
My setup is that kmail starts minimized to tray. And when I close window, it normally is still working in tray.
However, after upgrade to kde-unstable (I am on Arch, kmail package is 24.01.80-3), it behaves wrong.

STEPS TO REPRODUCE
0. Configure KMail so it can be closed to tray.
1. Start Kmail (may be autostarted at login) 
2. Click the tray icon to show main window.
3. Close the window. The window closes and the tray icon still shown (as expected).
4. Click the tray icon again to show main window.
5. Try to close window now.

OBSERVED RESULT
There is no reaction on close button. You can press Ctrl Q or just kill the window with Ctrl + Meta + Esc, but then the application terminates (no more tray icon).

EXPECTED RESULT
The window should be closed normally, and the app should continue working in tray.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.90.0
KDE Frameworks Version: 5.246.0
Qt Version: 6.6.1
Kernel Version: 6.6.7-arch1-1 (64-bit)
Graphics Platform: Wayland

Additional info:
After killing the window, relaunching kmail shows the message that it failed to start. Second start however normally start the kmail. And then the bug of unclosable window can be reproduced.
Comment 1 Vincenc Elias 2023-12-19 19:25:16 UTC
Thank you for your report!
I can replicate the bug on the latest unstable kde neon with kmail version 5.240.85 beta 2.
Comment 2 Nicolas Fella 2023-12-20 19:01:48 UTC
I see this with Ruqola too. Presumably an issue with KStatusNotifierItem
Comment 3 Nicolas Fella 2023-12-20 19:02:31 UTC
*** Bug 478776 has been marked as a duplicate of this bug. ***
Comment 4 Nicolas Fella 2023-12-21 00:07:20 UTC
Looks like a Qt bug: https://bugreports.qt.io/browse/QTBUG-120316
Comment 5 Andrew Shark 2024-01-20 20:05:08 UTC
I have found a good workaround. To keep the window "closable to tray", you can "close to tray" it by clicking on the tray icon.
This works at least for Kmail.
Comment 6 Andrew Shark 2024-01-29 09:29:02 UTC
With bug 443129  fixed, we now can use another convenience hack - make the window unclosable. So we do not close it with button by accident.
Comment 7 Nicolas Fella 2024-02-11 04:20:11 UTC
*** Bug 481135 has been marked as a duplicate of this bug. ***
Comment 8 Nicolas Fella 2024-02-11 04:21:05 UTC
https://invent.kde.org/frameworks/kstatusnotifieritem/-/merge_requests/11 works around this