From 947045b018b9dbb151344bab0a9eb3a7a94d0765 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 11 Dec 2009 20:22:52 +0000 Subject: [PATCH] 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 --- extenders/extender.cpp | 9 +++++++++ extenders/extender.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/extenders/extender.cpp b/extenders/extender.cpp index cc4ba3b72..4d283f9c9 100644 --- a/extenders/extender.cpp +++ b/extenders/extender.cpp @@ -551,6 +551,7 @@ void ExtenderPrivate::addExtenderItem(ExtenderItem *item, const QPointF &pos) return; } + QObject::connect(item, SIGNAL(destroyed(QObject *)), q, SLOT(extenderItemDestroyed(QObject *))); attachedExtenderItems.append(item); q->itemHoverLeaveEvent(item); q->itemAddedEvent(item, pos); @@ -721,6 +722,14 @@ ExtenderGroup *ExtenderPrivate::findGroup(const QString &name) const return 0; } +void ExtenderPrivate::extenderItemDestroyed(QObject *object) +{ + ExtenderItem *item = qobject_cast(object); + if (item && attachedExtenderItems.contains(item)) { + removeExtenderItem(item); + } +} + bool Extender::isEmpty() const { //If there are no items or only groups, consider this extender empty diff --git a/extenders/extender.h b/extenders/extender.h index a4aa8ad7c..bd4b21119 100644 --- a/extenders/extender.h +++ b/extenders/extender.h @@ -298,6 +298,8 @@ class PLASMA_EXPORT Extender : public QGraphicsWidget private: ExtenderPrivate *const d; + Q_PRIVATE_SLOT(d, void extenderItemDestroyed(QObject *object)) + friend class ExtenderPrivate; friend class ExtenderGroup; friend class ExtenderGroupPrivate;