remove the item pointer from all collections when it is deleted as it is also added to all of them when first added

BUG:263565

svn path=/trunk/KDE/kdelibs/; revision=1215440
This commit is contained in:
Aaron J. Seigo 2011-01-18 18:59:27 +00:00
parent 75a0733210
commit ef64072b4a

View File

@ -489,7 +489,7 @@ void Extender::dropEvent(QGraphicsSceneDragDropEvent *event)
void Extender::itemAddedEvent(ExtenderItem *item, const QPointF &pos) void Extender::itemAddedEvent(ExtenderItem *item, const QPointF &pos)
{ {
ExtenderGroup *group = item->isGroup()?static_cast<ExtenderGroup*>(item):0; ExtenderGroup *group = item->isGroup() ? static_cast<ExtenderGroup*>(item) : 0;
if (group && group->autoHide() && group->items().isEmpty()) { if (group && group->autoHide() && group->items().isEmpty()) {
return; return;
} }
@ -670,7 +670,7 @@ void ExtenderPrivate::addExtenderItem(ExtenderItem *item, const QPointF &pos)
QObject::connect(item, SIGNAL(destroyed(Plasma::ExtenderItem*)), q, SLOT(extenderItemDestroyed(Plasma::ExtenderItem*))); QObject::connect(item, SIGNAL(destroyed(Plasma::ExtenderItem*)), q, SLOT(extenderItemDestroyed(Plasma::ExtenderItem*)));
attachedExtenderItems.append(item); attachedExtenderItems.append(item);
q->itemHoverLeaveEvent(item); q->itemHoverLeaveEvent(item);
pendingItems[item] = pos; pendingItems.insert(item, pos);
QTimer::singleShot(0, q, SLOT(delayItemAddedEvent())); QTimer::singleShot(0, q, SLOT(delayItemAddedEvent()));
} }
@ -874,12 +874,11 @@ ExtenderGroup *ExtenderPrivate::findGroup(const QString &name) const
void ExtenderPrivate::extenderItemDestroyed(Plasma::ExtenderItem *item) void ExtenderPrivate::extenderItemDestroyed(Plasma::ExtenderItem *item)
{ {
if (item && attachedExtenderItems.contains(item)) { pendingItems.remove(item);
if (attachedExtenderItems.contains(item)) {
// removeExtenderItem also removes the item from attachedExtenderItems
removeExtenderItem(item); removeExtenderItem(item);
} else if (pendingItems.contains(item)) {
pendingItems.remove(item);
} else {
attachedExtenderItems.removeAll(item);
} }
} }