Skip to content

KHamburgerMenu: Avoid null receiver warning upon showing menubar

After 09660e64, each application using KHamburgerMenu would show a warning upon showing the menubar either on startup, or when manually activating it via the "Show Menubar" action's keyboard shortcut "Ctrl+M": QCoreApplication::postEvent: Unexpected null receiver

This happens because QObject::deleteLater() is implemented as QCoreApplication::postEvent(this, new QDeferredDeleteEvent());, leading to a warning if this, i.e. the pointer guarded by m_actualMenu, is a nullptr. The latter condition holds on startup, and during runtime when the menubar has been hidden again without the hamburger menu having been opened yet.

The warning can be avoided by not triggering the unnecessary delete if m_actualMenu is null already.

Test Plan:

  • No warning when Okular is started with a menubar shown by default.
  • No warning when repeatedly showing the menubar with "Ctrl+M".

Merge request reports