Bug 381492

Summary: KSelectAction::~KSelectAction calls deleteLater() on NULL QMenu* instance
Product: [Frameworks and Libraries] frameworks-kwidgetsaddons Reporter: RJVB <rjvbertin>
Component: generalAssignee: Christoph Feck <cfeck>
Status: RESOLVED WORKSFORME    
Severity: normal CC: kdelibs-bugs
Priority: NOR    
Version: 5.35.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description RJVB 2017-06-21 16:40:26 UTC
After updating to FW 5.35.0 I started seeing `QCoreApplication::postEvent: Unexpected null receiver` errors on the calling terminal.

I traced those to the KSelectAction dtor that calls `menu()->deleteLater()` without checking first if `menu()` returns non-null.

In turn it appears that function returns NULL because of a now-reverted change in KXmlGui (#b5af0296cb).

Still, is it safe to assume that `KSelectAction::menu()` never returns NULL (in the dtor and elsewhere in the file)?
Comment 1 Christoph Feck 2017-06-26 19:01:23 UTC
According to the code, only in init() there is a call to QAction::setMenu() with a newly created QMenu without a parent, and it is never changed later, so QAction::menu() should still return this menu when deleting.

Since the menu is probably reparented to other objects while it is shown, the code that does the reparenting should make sure the parent relationship is removed later.

Do you have an idea which code is responsible for changing the parent?
Comment 2 RJVB 2017-06-26 20:29:49 UTC
> Do you have an idea which code is responsible for changing the parent?

No, not at the moment.

There is 1 possibility: Qt itself reparents actions that are added to a menu that's part of a native menubar.

I guess I might hope to get some answers by breaking in QAction::setMenu() if it's called with a NULL pointer?
Comment 3 Justin Zobel 2022-11-06 09:24:51 UTC
Thank you for reporting this issue in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version?

If you can reproduce the issue, please change the status to "REPORTED" when replying. Thank you!
Comment 4 Bug Janitor Service 2022-11-21 05:13:54 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 5 Bug Janitor Service 2022-12-06 05:20:37 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!