From kde-commits Thu Sep 18 11:23:18 2008 From: David Faure Date: Thu, 18 Sep 2008 11:23:18 +0000 To: kde-commits Subject: KDE/kdelibs/kdeui/actions Message-Id: <1221736998.812335.18469.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=122173700821684 SVN commit 862271 by dfaure: Fix unit test breakage; inserting the same action twice with two different names didn't remove the first name anymore, because of r860727 removing the data structure that was storing the old name. Michael, can I suggest adding tests in kactioncollectiontest for the kactioncategory-related behavior? CCMAIL: kde@michael-jansen.biz M +11 -4 kactioncollection.cpp --- trunk/KDE/kdelibs/kdeui/actions/kactioncollection.cpp #862270:862271 @@ -220,6 +220,7 @@ if (!action) return action; + const QString origName = action->objectName(); QString index_name = name; if (index_name.isEmpty()) @@ -250,7 +251,13 @@ } // Check if we have this action under a different name. - takeAction(action); + // Not using takeAction because we don't want to remove it from categories, + // and because it has the new name already. + const int oldIndex = d->actions.indexOf(action); + if (oldIndex != -1) { + d->actionByName.remove(origName); + d->actions.removeAt(oldIndex); + } // Add action to our lists. d->actionByName.insert(index_name, action); @@ -475,7 +482,7 @@ QString actionName = it.key(); bool bSameAsDefault = (kaction->shortcut() == kaction->shortcut(KAction::DefaultShortcut)); - kDebug(129) << "name = " << actionName + kDebug(129) << "name = " << actionName << " shortcut = " << kaction->shortcut(KAction::ActiveShortcut).toString() << " globalshortcut = " << kaction->globalShortcut(KAction::ActiveShortcut).toString() << " def = " << kaction->shortcut(KAction::DefaultShortcut).toString(); @@ -607,7 +614,7 @@ if (d->connectHovered && d->connectTriggered) return; - if (QMetaObject::normalizedSignature(SIGNAL(actionHighlighted(QAction*))) == signal || + if (QMetaObject::normalizedSignature(SIGNAL(actionHighlighted(QAction*))) == signal || QMetaObject::normalizedSignature(SIGNAL(actionHovered(QAction*))) == signal) { if (!d->connectHovered) { d->connectHovered = true; @@ -680,7 +687,7 @@ // Remove the action actionByName.remove(name); - actions.takeAt(index); + actions.removeAt(index); // Remove the action from the categories. Should be only one QList categories = q->findChildren();