make sure to not call the delayed itemaddedevent twice: the queue becomes an hash.

the counterindication is that the order now is kinda indeterministinc but *shouldn't* give problems

svn path=/trunk/KDE/kdelibs/; revision=1185200
This commit is contained in:
Marco Martin 2010-10-12 14:36:46 +00:00
parent c79712f294
commit b3b18e5d7e
2 changed files with 8 additions and 6 deletions
extenders
private

@ -644,6 +644,7 @@ ExtenderPrivate::~ExtenderPrivate()
void ExtenderPrivate::addExtenderItem(ExtenderItem *item, const QPointF &pos) void ExtenderPrivate::addExtenderItem(ExtenderItem *item, const QPointF &pos)
{ {
if (attachedExtenderItems.contains(item)) { if (attachedExtenderItems.contains(item)) {
pendingItems.remove(item);
q->itemAddedEvent(item, pos); q->itemAddedEvent(item, pos);
return; return;
} }
@ -651,7 +652,7 @@ void ExtenderPrivate::addExtenderItem(ExtenderItem *item, const QPointF &pos)
QObject::connect(item, SIGNAL(destroyed(ExtenderItem*)), q, SLOT(extenderItemDestroyed(ExtenderItem*))); QObject::connect(item, SIGNAL(destroyed(ExtenderItem*)), q, SLOT(extenderItemDestroyed(ExtenderItem*)));
attachedExtenderItems.append(item); attachedExtenderItems.append(item);
q->itemHoverLeaveEvent(item); q->itemHoverLeaveEvent(item);
pendingItems.append(QPair<ExtenderItem *, QPointF>(item, pos)); pendingItems[item] = pos;
QTimer::singleShot(0, q, SLOT(delayItemAddedEvent())); QTimer::singleShot(0, q, SLOT(delayItemAddedEvent()));
} }
@ -795,11 +796,12 @@ void ExtenderPrivate::updateBorders()
void ExtenderPrivate::delayItemAddedEvent() void ExtenderPrivate::delayItemAddedEvent()
{ {
while (!pendingItems.isEmpty()) { QHash<Plasma::ExtenderItem *, QPointF>::const_iterator i = pendingItems.constBegin();
QPair<Plasma::ExtenderItem *, QPointF> item = pendingItems.first(); while (i != pendingItems.constEnd()) {
q->itemAddedEvent(item.first, item.second); q->itemAddedEvent(i.key(), i.value());
pendingItems.pop_front(); ++i;
} }
pendingItems.clear();
} }
void ExtenderPrivate::updateEmptyExtenderLabel() void ExtenderPrivate::updateEmptyExtenderLabel()

@ -99,7 +99,7 @@ class ExtenderPrivate
bool destroying; bool destroying;
bool scrollbarVisible; bool scrollbarVisible;
QList<QPair<ExtenderItem *, QPointF> > pendingItems; QHash<ExtenderItem *, QPointF> pendingItems;
}; };
} // namespace Plasma } // namespace Plasma