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;