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

View File

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

View File

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