From 813f6a088ff485000e2fc9efe14b90d3f2c5058f Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 16 Mar 2010 18:35:07 +0000 Subject: [PATCH] clear this bit of code up svn path=/trunk/KDE/kdelibs/; revision=1104111 --- extenders/extenderitem.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/extenders/extenderitem.cpp b/extenders/extenderitem.cpp index 2b4fe5130..73391fcac 100644 --- a/extenders/extenderitem.cpp +++ b/extenders/extenderitem.cpp @@ -772,16 +772,15 @@ void ExtenderItemPrivate::updateToolBox() } //add the actions that are actually set to visible. + QAction *closeAction = actions.value("close"); foreach (QAction *action, actionsInOrder) { - if (action->isVisible()) { + if (action->isVisible() && action != closeAction) { IconWidget *icon = new IconWidget(q); icon->setAction(action); QSizeF size = icon->sizeFromIconSize(iconSize); icon->setMinimumSize(size); icon->setMaximumSize(size); - if (action != actions.value("close")) { - toolboxLayout->addItem(icon); - } + toolboxLayout->addItem(icon); } } @@ -800,23 +799,21 @@ void ExtenderItemPrivate::updateToolBox() //add the close icon if desired. if (destroyActionVisibility) { destroyButton = new IconWidget(q); - if (!actions.contains("close")) { - QAction *destroyAction = new QAction(q); - actions["close"] = destroyAction; + if (!closeAction) { + closeAction = new QAction(q); + actions.insert("close", closeAction); + QObject::connect(closeAction, SIGNAL(triggered()), q, SLOT(destroy())); } - destroyButton->setAction(actions["close"]); + destroyButton->setAction(closeAction); destroyButton->setSvg("widgets/configuration-icons", "close"); QSizeF size = destroyButton->sizeFromIconSize(iconSize); destroyButton->setMinimumSize(size); destroyButton->setMaximumSize(size); - toolboxLayout->addItem(destroyButton); - - QObject::connect(actions["close"], SIGNAL(triggered()), q, SLOT(destroy())); - } else if (actions.contains("close")) { - QAction *destroyAction = actions["close"]; + } else if (closeAction) { actions.remove("close"); - destroyAction->deleteLater(); + closeAction->deleteLater(); + closeAction = 0; } toolboxLayout->updateGeometry();