Fix handling of placeholder actions with toolbars/toolbuttons
authorTobias Koenig <tobias.koenig@kdab.com>
Wed, 28 Nov 2012 10:43:50 +0000 (11:43 +0100)
committerTobias Koenig <tobias.koenig@kdab.com>
Wed, 28 Nov 2012 10:43:50 +0000 (11:43 +0100)
lib/objectadaptors.cpp

index b7f10f3..04e5494 100644 (file)
@@ -59,15 +59,13 @@ void ActionItem::setAction(const QVariant &action)
   // Check if the placeholder must be replaced with the actual action
   if (m_qAction == m_placeholderAction) {
     const QList<QWidget*> widgets = m_placeholderAction->associatedWidgets();
-    if (!widgets.isEmpty()) {
-      Q_ASSERT(widgets.count() == 1); // The placeholder action can only be plugged into one widget
-
+    foreach (QWidget *widget, widgets) {
       // Replace the placeholder action with the new one
-      widgets.first()->insertAction(m_placeholderAction, newAction);
-      widgets.first()->removeAction(m_placeholderAction);
-
-      m_qAction = newAction;
+      widget->insertAction(m_placeholderAction, newAction);
+      widget->removeAction(m_placeholderAction);
     }
+
+    m_qAction = newAction;
   }
 
   emit actionChanged();