remove the extender item from attachedExtenderItems if it gets destroyed for whatever reason

hopefully fixes some crashers, such as
BUG:217942


svn path=/trunk/KDE/kdelibs/; revision=1061477
This commit is contained in:
Marco Martin 2009-12-11 20:22:52 +00:00
parent 48af57c6ce
commit 947045b018
2 changed files with 11 additions and 0 deletions

View File

@ -551,6 +551,7 @@ void ExtenderPrivate::addExtenderItem(ExtenderItem *item, const QPointF &pos)
return; return;
} }
QObject::connect(item, SIGNAL(destroyed(QObject *)), q, SLOT(extenderItemDestroyed(QObject *)));
attachedExtenderItems.append(item); attachedExtenderItems.append(item);
q->itemHoverLeaveEvent(item); q->itemHoverLeaveEvent(item);
q->itemAddedEvent(item, pos); q->itemAddedEvent(item, pos);
@ -721,6 +722,14 @@ ExtenderGroup *ExtenderPrivate::findGroup(const QString &name) const
return 0; return 0;
} }
void ExtenderPrivate::extenderItemDestroyed(QObject *object)
{
ExtenderItem *item = qobject_cast<ExtenderItem *>(object);
if (item && attachedExtenderItems.contains(item)) {
removeExtenderItem(item);
}
}
bool Extender::isEmpty() const bool Extender::isEmpty() const
{ {
//If there are no items or only groups, consider this extender empty //If there are no items or only groups, consider this extender empty

View File

@ -298,6 +298,8 @@ class PLASMA_EXPORT Extender : public QGraphicsWidget
private: private:
ExtenderPrivate *const d; ExtenderPrivate *const d;
Q_PRIVATE_SLOT(d, void extenderItemDestroyed(QObject *object))
friend class ExtenderPrivate; friend class ExtenderPrivate;
friend class ExtenderGroup; friend class ExtenderGroup;
friend class ExtenderGroupPrivate; friend class ExtenderGroupPrivate;