From 23c52d1e2d4378dd22b3a9a5047c4b08ec07d3a5 Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Sun, 23 Aug 2009 01:13:36 +0000 Subject: [PATCH] guard against use of setParent svn path=/trunk/KDE/kdelibs/; revision=1014484 --- containmentactions.cpp | 13 ++++++++++++- containmentactions.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/containmentactions.cpp b/containmentactions.cpp index 0c3945d33..fa83abb0b 100644 --- a/containmentactions.cpp +++ b/containmentactions.cpp @@ -133,7 +133,7 @@ PackageStructure::Ptr ContainmentActions::packageStructure() Containment *ContainmentActions::containment() { - return static_cast(parent()); + return qobject_cast(parent()); } QString ContainmentActions::name() const @@ -299,6 +299,17 @@ void ContainmentActions::paste(QPointF scenePos, QPoint screenPos) } } +bool ContainmentActions::event(QEvent *e) +{ + if (e->type() == QEvent::ParentChange) { + if (!containment()) { + //some fool took away our containment. run away, run away! + deleteLater(); + } + } + return false; +} + } // Plasma namespace #include "containmentactions.moc" diff --git a/containmentactions.h b/containmentactions.h index 15813ffaf..261c47fc5 100644 --- a/containmentactions.h +++ b/containmentactions.h @@ -206,6 +206,8 @@ class PLASMA_EXPORT ContainmentActions : public QObject */ static QString eventToString(QEvent *event); + bool event(QEvent *e); + protected: /** * This constructor is to be used with the plugin loading systems