guard against use of setParent

svn path=/trunk/KDE/kdelibs/; revision=1014484
This commit is contained in:
Chani Armitage 2009-08-23 01:13:36 +00:00
parent f9317c11e6
commit 23c52d1e2d
2 changed files with 14 additions and 1 deletions

View File

@ -133,7 +133,7 @@ PackageStructure::Ptr ContainmentActions::packageStructure()
Containment *ContainmentActions::containment()
{
return static_cast<Containment*>(parent());
return qobject_cast<Containment*>(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"

View File

@ -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