SVN commit 1237516 by kylafas: juk: fix crash when adding items to toolbars with RMB. When adding an item to a toolbar using right-click, the KXMLGUIClient object of the global action collection is accessed. (see KMenuMenuHandler::slotAddToToolBar() ) The way the action collection was created meant the object was NULL, which resulted in crashes. So, create the action collection with KXMLGUIClient::actionCollection(), which properly sets the object. CCBUG: 258641 M +11 -2 actioncollection.cpp M +0 -5 juk.cpp M +0 -1 juk.h --- trunk/KDE/kdemultimedia/juk/actioncollection.cpp #1237515:1237516 @@ -14,6 +14,7 @@ ***************************************************************************/ #include "actioncollection.h" +#include "juk.h" #include #include @@ -22,8 +23,16 @@ { KActionCollection *actions() { - static KActionCollection *a = - new KActionCollection(static_cast(0)); + // Use KXMLGUIClient::actionCollection() (class JuK derives from + // KXMLGUIClient) to construct the KActionCollection. + // This makes sure that KActionCollection::parentGUIClient() is not + // NULL and prevents the application from crashing when adding an + // item to a toolbar using RMB (see bug #258641). + // XXX This should not just be: + // return JuK::JuKInstance()->actionCollection(); + // as actions() may be called while within JuK's dtor, in which case + // JuKInstance()->... would result to a crash. + static KActionCollection *a = JuK::JuKInstance()->actionCollection(); // The widget of the action collection is set in Juk::setupActions(). return a; } --- trunk/KDE/kdemultimedia/juk/juk.cpp #1237515:1237516 @@ -135,11 +135,6 @@ { } -KActionCollection *JuK::actionCollection() const -{ - return ActionCollection::actions(); -} - JuK* JuK::JuKInstance() { return m_instance; --- trunk/KDE/kdemultimedia/juk/juk.h #1237515:1237516 @@ -38,7 +38,6 @@ public: JuK(QWidget* parent = 0); virtual ~JuK(); - virtual KActionCollection *actionCollection() const; static JuK* JuKInstance();