KStandardAction::showMenubar() lacks collection->addAction()

Christian Esken esken at kde.org
Wed Jun 20 21:53:24 BST 2007


Hello,

I just realized that the standard action ShowMenubar doesn't show up in KMix (latest trunk).

kstandardaction.cpp looks guilty, as it calls KStandardAction::create() (and this calls collection->addAction() ) for virtually all actions, except showMenubar(), showToolbar() and fullScreen().

It works, if I call addAction() manually in my application code.
   KAction *a = KStandardAction::showMenubar( this, SLOT(toggleMenuBar()), actionCollection());
   actionCollection()->addAction( a->objectName(), a );   # <<< added

Is this intendend behaviour or a bug?

    Christian


The patch is probably simple:

kde at bjork:/opt/SVN/kdelibs/kdeui/actions> diff -u kstandardaction.cpp kstandardaction.cpp.addAction
--- kstandardaction.cpp 2007-06-10 11:22:29.000000000 +0200
+++ kstandardaction.cpp.addAction       2007-06-20 22:42:19.000000000 +0200
@@ -462,6 +462,10 @@

   ret->setChecked( true );

+  KActionCollection *collection = qobject_cast<KActionCollection *>(parent);
+  if (ret && collection)
+      collection->addAction(ret->objectName(), ret);
+
   return ret;
 }

But it also has to be done for showToolbar() and fullScreen(), and I wonder why there is a switch case for ShowMenubar in KStandardAction::create(), if it isn't called.


  Christian
 
-- 
Things should be made as simple as possible, but no simpler. 
  - Albert Einstein




More information about the kde-core-devel mailing list