Bug 485661

Summary: Kmail popup windows closes when trying to copy or move message to folder
Product: [Applications] kmail2 Reporter: Gerald <gerald.drissner>
Component: UIAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: achimxm369, adam, barryvdean, benjarobin+kde, bjb01234, bugs.kde.org, christophe, chwallac, colin.thomson, correlander, david.decos, davispuh, dtombaugh, fischer, heri+kde, jlp, jranke, kaeslaek, luisfe, natesitton80, nicolas.fella, pericam, personal, rnbzilla, rob.dyck, roland.brand, senf, timfolger, todd.lasman, tommy.glading, winter, zvrabec001
Priority: VHI    
Version First Reported In: 6.0.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 6.5.2
Sentry Crash Report:

Description Gerald 2024-04-17 06:42:03 UTC
***
If I want to copy a message to a folder (right mouse button - Message - copy to folder), the popup window is killed as soon as I click on copy to folder. I cannot select a folder. 
***

SUMMARY


STEPS TO REPRODUCE
1. Mark Message 
2. Right click - copy or move message to
3. Popup window closes automatically (before you can even select a folder)

OBSERVED RESULT
Popup window closes automatically

EXPECTED RESULT
I should be able to select to folder to which I want to copy or move the message

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma:  6.0.3 (wayland)
(available in About System)
KDE Plasma Version: 6.0.3
KDE Frameworks Version:  6.1.0
Qt Version: 6.7

ADDITIONAL INFORMATION
Comment 1 Roger Noble 2024-05-15 09:26:52 UTC
Happens with me as well. Also when trying to move a message between folders: the menu disappears as soon as I try to move below the Recent Folder item.
Comment 2 rob.dyck 2024-06-11 01:01:52 UTC
plasma 6.0.5
frameworks 6.3.0
QT 6.7.1
In other words, not fixed
Comment 3 rob.dyck 2024-06-11 01:02:14 UTC
plasma 6.0.5
frameworks 6.3.0
QT 6.7.1
In other words, not fixed
Comment 4 rob.dyck 2024-06-11 01:02:30 UTC
plasma 6.0.5
frameworks 6.3.0
QT 6.7.1
In other words, not fixed
Comment 5 Roger Noble 2024-07-18 10:57:31 UTC
This bug is still there in kmail 6.1.2, frameworks 6.3.0. It's really frustrating. I have messages in folders I can't move or copy because of this.
Comment 6 rob.dyck 2024-08-30 18:14:33 UTC
Still exists in Plasma6.1.4 and applications 24.8.0.

Side note
Dragging a message to a folder works. It;s just a problem with the secondary menu.
Comment 7 Colin J Thomson 2024-08-30 18:29:52 UTC
Also seeing this with the menu, as mentioned in comment #6 it works fine when dragging the messages.

Operating System: Fedora Linux 40
KDE Gear 24.08.0-1
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.10.7-200.fc40.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 8 adam 2024-09-04 15:19:05 UTC
This bug makes kmail extremely clunky to use and is new in Plasma 6. 

This behaviour is observed both when right clicking on a message and trying to get to a folder to copy or move to, or by starting from the menus in the menu bar -- Message -> Copy or Move Message To ... -> Anything in the folder list

Operating System: Gentoo
KDE Gear 24.05.2
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.10.7-gentoo-x86_64
Graphics Platform: Wayland
Comment 9 Roger Noble 2024-10-10 11:53:29 UTC
Since 24.08.1 it's got worse. Now I can't even use any of the Move Message To or Copy Message To entries, the menu just disappears as soon as the mouse is moved over these items. Previously at least the recently used folders items were accessible. Qt 6.7.2, frameworks 6.6.0, plasma 6.2.0.
Comment 10 Colin J Thomson 2024-10-10 18:34:44 UTC
(In reply to Roger Noble from comment #9)
> Since 24.08.1 it's got worse. Now I can't even use any of the Move Message
> To or Copy Message To entries, the menu just disappears as soon as the mouse
> is moved over these items. Previously at least the recently used folders
> items were accessible. Qt 6.7.2, frameworks 6.6.0, plasma 6.2.0.

I am seeing the same here with 24.08.2
Comment 11 Thomas Fischer 2024-10-21 12:41:20 UTC
Can confirm the problem with Fedora Linux 40:
KMail 24.08.2
Qt 6.7.2
KDE Frameworks 6.7.0
Comment 12 adam 2024-10-22 20:05:28 UTC
(In reply to adam from comment #8)
> This bug makes kmail extremely clunky to use and is new in Plasma 6. 
> 
> This behaviour is observed both when right clicking on a message and trying
> to get to a folder to copy or move to, or by starting from the menus in the
> menu bar -- Message -> Copy or Move Message To ... -> Anything in the folder
> list
> 
> Operating System: Gentoo
> KDE Gear 24.05.2
> KDE Plasma Version: 6.1.4
> KDE Frameworks Version: 6.5.0
> Qt Version: 6.7.2
> Kernel Version: 6.10.7-gentoo-x86_64
> Graphics Platform: Wayland

Still occurring with KMail 24.08.1, QT 6.7.2, and KDE Frameworks 6.6.0 (and newer according to other comments here)
Comment 13 Colin J Thomson 2024-11-05 17:40:26 UTC
*** Bug 495833 has been marked as a duplicate of this bug. ***
Comment 14 Achim25 2024-11-06 05:36:38 UTC
(In reply to Roger Noble from comment #9)
> Seit dem 24.08.1 ist es noch schlimmer geworden. Jetzt kann ich nicht einmal
> mehr die Einträge „Nachricht verschieben nach“ oder „Nachricht kopieren
> nach“ verwenden, das Menü verschwindet einfach, sobald die Maus über diese
> Elemente bewegt wird. Zuvor waren zumindest die Elemente der zuletzt
> verwendeten Ordner zugänglich. Qt 6.7.2, Frameworks 6.6.0, Plasma 6.2.0.

So ist es bei mir auch. Dann sollte sich schnell was ändern. Ich finde es schade!
Comment 15 Colin J Thomson 2024-11-25 08:47:47 UTC
FWIW, I still see this issue with Gear 24.11.80 beta with plasma and frameworks from git.
It only seems to be the "copy to" and "move to" options in every window, msg list, mail body, folder list etc. 

I tested "copy to and move to"  in other applications and it works as it should.

Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.80
KDE Frameworks Version: 6.9.0
Qt Version: 6.8.0
Kernel Version: 6.11.10-300.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 16 Roland Brand 2024-12-19 06:49:32 UTC
The issue seems to be related to the Wayland graphics platform. I switched back to X11, and moving messages works fine.

Operating System: Debian GNU/Linux 12
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.7.2
Kernel Version: 6.11.10-amd64 (64-bit)
Graphics Platform: X11
Comment 17 Thomas Fischer 2024-12-19 13:20:07 UTC
(In reply to Roland Brand from comment #16)
> The issue seems to be related to the Wayland graphics platform. I switched
> back to X11, and moving messages works fine.
I can confirm this. There is no need to switch back to X11 for everything. Launching KMail the following way does the same trick:
QT_QPA_PLATFORM=xcb /usr/bin/kmail
See also:
https://community.kde.org/KWin/Wayland#Forcing_KDE_apps_to_run_as_X11
Comment 18 Colin J Thomson 2024-12-21 16:47:02 UTC
(In reply to Thomas Fischer from comment #17)
> I can confirm this. There is no need to switch back to X11 for everything.
> Launching KMail the following way does the same trick:
> QT_QPA_PLATFORM=xcb /usr/bin/kmail

Thanks for this, QT_QPA_PLATFORM=xcb /usr/bin/kontact works for me.
I wonder if the "product" should be moved to wayland?

Operating System: Fedora Linux 41
KDE Gear 24.12.0-1
KDE Plasma Version: 6.2.80
KDE Frameworks Version: 6.10.0
Qt Version: 6.9.0
Kernel Version: 6.12.6-200.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 19 Colin J Thomson 2025-01-13 20:40:00 UTC
*** Bug 498617 has been marked as a duplicate of this bug. ***
Comment 20 Nicolas Fella 2025-02-03 22:57:18 UTC
*** Bug 499323 has been marked as a duplicate of this bug. ***
Comment 21 Nicolas Fella 2025-02-09 16:03:31 UTC
This is related to the lines https://invent.kde.org/pim/akonadi/-/blob/master/src/widgets/standardactionmanager.cpp#L489

If I remove the 

delete menu;
menu = new QMenu();

then it doesn't close
Comment 22 Colin J Thomson 2025-02-16 23:00:24 UTC
*** Bug 495943 has been marked as a duplicate of this bug. ***
Comment 23 Colin J Thomson 2025-02-24 20:42:47 UTC
*** Bug 500689 has been marked as a duplicate of this bug. ***
Comment 24 Dennis Schridde 2025-03-14 09:07:51 UTC
*** Bug 501421 has been marked as a duplicate of this bug. ***
Comment 25 kaeslaek 2025-03-14 12:00:16 UTC
Also still seeing this issue with:

Operating System: Fedora Linux 41
KDE Plasma Version: 6.3.2
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2
Kernel Version: 6.13.5-200.fc41.x86_64 (64-bit)
Graphics Platform: Wayland 

Starting kmail with "QT_QPA_PLATFORM=xcb kmail" makes it work but I see a black flicker for a split second the first time the menu opens. Not all the time so hard to capture.
Comment 26 Colin J Thomson 2025-03-30 00:55:11 UTC
*** Bug 502183 has been marked as a duplicate of this bug. ***
Comment 27 Colin J Thomson 2025-05-07 16:36:11 UTC
*** Bug 503876 has been marked as a duplicate of this bug. ***
Comment 28 Stagger Lee 2025-05-27 08:09:22 UTC
Still issue in the latest ArchLinux versions.
Comment 29 rob.dyck 2025-06-21 14:25:24 UTC
Still an issue after updating to Plasma 6.4
Comment 30 Colin J Thomson 2025-07-04 23:36:42 UTC
*** Bug 506594 has been marked as a duplicate of this bug. ***
Comment 31 Tom 2025-08-10 21:35:05 UTC
I think that this is related but I am unsure of how to test.

You also can move mail using using the Filter Rules option "Move Into Folder".

When I attempted to set a filter like this, the filter ran for a few seconds and did nothing. Attempting to use the filter again resulted in nothing happening on the computer.
Comment 32 Barry 2025-08-18 15:45:06 UTC
(In reply to Colin J Thomson from comment #18)
> (In reply to Thomas Fischer from comment #17)
> > I can confirm this. There is no need to switch back to X11 for everything.
> > Launching KMail the following way does the same trick:
> > QT_QPA_PLATFORM=xcb /usr/bin/kmail
> 
> Thanks for this, QT_QPA_PLATFORM=xcb /usr/bin/kontact works for me.
> I wonder if the "product" should be moved to wayland?
> 
> Operating System: Fedora Linux 41
> KDE Gear 24.12.0-1
> KDE Plasma Version: 6.2.80
> KDE Frameworks Version: 6.10.0
> Qt Version: 6.9.0
> Kernel Version: 6.12.6-200.fc41.x86_64 (64-bit)
> Graphics Platform: Wayland

I did this workaround for kontact and kmail now works as expected. Looks like a possible Wayland issue.
Comment 33 Colin J Thomson 2025-08-20 16:32:25 UTC
*** Bug 508507 has been marked as a duplicate of this bug. ***
Comment 34 Johannes Ranke 2025-08-25 19:37:46 UTC
Also affected:

Operating System: Debian 13
KDE Plasma Version: 6.3.6
KDE Frameworks Version: 6.13.0
Qt Version: 6.8.2
Kernel Version: 6.12.38+deb13-amd64 (64-bit)
Graphics Platform: Wayland
Comment 35 Benjamin Robin 2025-09-06 16:46:40 UTC
I start to investigate this issue. Thank to @NicolasFella for the initial help!

The root cause is in akonadi standardactionmanager.cpp, the function clipboardChanged() is called somehow when right-clicking and even when going over a menu. Which in turn generates the following call stack:
 - updateActions() 
 - ActionStateManager::updateState()
 - ActionStateManager::enableAction() 
 - enableAction()
 - delete menu.

So when we go over a sub-menu, this delete the associated submenu (delete menu), which closes this submenu (which is normal since deleted)...
Do now, the question is why, under Wayland, the function clipboardChanged() is called so often!
Comment 36 Benjamin Robin 2025-09-06 20:40:33 UTC
For information, this issue (clipboard data changed event generated when opening a menu) can be reproduced with a very basic Qt project. So maybe a fix needs to occur in Qt.

But right now, I have created a workaround, see: https://invent.kde.org/pim/akonadi/-/merge_requests/275
Comment 37 Dennis Schridde 2025-09-12 08:57:15 UTC
(In reply to Benjamin Robin from comment #36)
> For information, this issue (clipboard data changed event generated when
> opening a menu) can be reproduced with a very basic Qt project. So maybe a
> fix needs to occur in Qt.

Is there already a bug report against Qt?  (I could not find anything obviously related on https://bugreports.qt.io/)
Comment 38 Allen Winter 2025-09-12 10:17:15 UTC
Git commit 9738f63da4174c9d8b6abee328e15b3f5cd94cd6 by Allen Winter.
Committed on 12/09/2025 at 10:17.
Pushed by winterz into branch 'release/25.08'.

widgets/standardactionmanager: Filter clipboard change events

Under Wayland, QClipboard::changed signal is triggered very often, for
example each time a QMenu is opened, or when the focus of the main window
changed.
This is an issue because Actions (and associated QMenu) are updated for
various events, including the clipboard data change event. And when
updating Actions, the QMenu are updated: old sub-menu is destroyed which
close the sub-menu...

To fix that only update the actions when the clipboard truly changed.
Related: bug 508727


(cherry picked from commit 5c1aba602aa461dcf06dfe8b23f52df074b3f35c)

Co-authored-by: Benjamin Robin <benjamin.robin@bootlin.com>

M  +1    -1    autotests/libs/actionstatemanagertest.cpp
M  +41   -32   src/core/pastehelper.cpp
M  +8    -0    src/core/pastehelper_p.h
M  +5    -2    src/widgets/actionstatemanager.cpp
M  +3    -1    src/widgets/actionstatemanager_p.h
M  +20   -6    src/widgets/standardactionmanager.cpp

https://invent.kde.org/pim/akonadi/-/commit/9738f63da4174c9d8b6abee328e15b3f5cd94cd6
Comment 39 Benjamin Robin 2025-09-12 11:27:44 UTC
(In reply to Dennis Schridde from comment #37)
> Is there already a bug report against Qt?  (I could not find anything
> obviously related on https://bugreports.qt.io/)

I did not take the time to create the bug report. I need to investigate a bit. Maybe I will do it this weekend.
Comment 40 Colin J Thomson 2025-09-12 22:43:15 UTC
Thanks for fixing this issue, which has also fixed the same problem in korganizer.