Add an appletDestroyed signal instead of catching the destruction in containments with qobject destroyed signal.
THis fix errors because we give an invalid pointer to public appletRemoved signal. svn path=/trunk/KDE/kdelibs/; revision=917619
This commit is contained in:
parent
ae301b3718
commit
ef4b6c7187
@ -134,6 +134,9 @@ Applet::Applet(QObject *parentObject, const QVariantList &args)
|
|||||||
|
|
||||||
Applet::~Applet()
|
Applet::~Applet()
|
||||||
{
|
{
|
||||||
|
//let people know that i will die
|
||||||
|
emit appletDestroyed(this);
|
||||||
|
|
||||||
if (!d->transient && d->extender) {
|
if (!d->transient && d->extender) {
|
||||||
//This would probably be nicer if it was located in extender. But in it's dtor, this won't
|
//This would probably be nicer if it was located in extender. But in it's dtor, this won't
|
||||||
//work since when that get's called, the applet's config() isn't accessible anymore. (same
|
//work since when that get's called, the applet's config() isn't accessible anymore. (same
|
||||||
|
5
applet.h
5
applet.h
@ -611,6 +611,11 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
|||||||
*/
|
*/
|
||||||
void activate();
|
void activate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when the applet is deleted
|
||||||
|
*/
|
||||||
|
void appletDestroyed(Plasma::Applet *applet);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Sets the immutability type for this applet (not immutable,
|
* Sets the immutability type for this applet (not immutable,
|
||||||
|
@ -734,7 +734,7 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit)
|
|||||||
|
|
||||||
connect(applet, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));
|
connect(applet, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));
|
||||||
connect(applet, SIGNAL(releaseVisualFocus()), this, SIGNAL(releaseVisualFocus()));
|
connect(applet, SIGNAL(releaseVisualFocus()), this, SIGNAL(releaseVisualFocus()));
|
||||||
connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletDestroyed(QObject*)));
|
connect(applet, SIGNAL(appletDestroyed(Plasma::Applet*)), this, SLOT(appletDestroyed(Plasma::Applet*)));
|
||||||
connect(applet, SIGNAL(activate()), this, SIGNAL(activate()));
|
connect(applet, SIGNAL(activate()), this, SIGNAL(activate()));
|
||||||
|
|
||||||
if (pos != QPointF(-1, -1)) {
|
if (pos != QPointF(-1, -1)) {
|
||||||
@ -1697,16 +1697,8 @@ bool ContainmentPrivate::regionIsEmpty(const QRectF ®ion, Applet *ignoredAppl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainmentPrivate::appletDestroyed(QObject *object)
|
void ContainmentPrivate::appletDestroyed(Plasma::Applet *applet)
|
||||||
{
|
{
|
||||||
// we do a static_cast here since it really isn't an Applet by this
|
|
||||||
// point anymore since we are in the qobject dtor. we don't actually
|
|
||||||
// try and do anything with it, we just need the value of the pointer
|
|
||||||
// so this unsafe looking code is actually just fine.
|
|
||||||
//
|
|
||||||
// NOTE: DO NOT USE THE applet VARIABLE FOR ANYTHING OTHER THAN COMPARING
|
|
||||||
// THE ADDRESS! ACTUALLY USING THE OBJECT WILL RESULT IN A CRASH!!!
|
|
||||||
Applet *applet = static_cast<Plasma::Applet*>(object);
|
|
||||||
applets.removeAll(applet);
|
applets.removeAll(applet);
|
||||||
if (focusedApplet == applet) {
|
if (focusedApplet == applet) {
|
||||||
focusedApplet = 0;
|
focusedApplet = 0;
|
||||||
|
@ -507,7 +507,7 @@ class PLASMA_EXPORT Containment : public Applet
|
|||||||
const QGraphicsItem *toolBoxItem() const;
|
const QGraphicsItem *toolBoxItem() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PRIVATE_SLOT(d, void appletDestroyed(QObject*))
|
Q_PRIVATE_SLOT(d, void appletDestroyed(Plasma::Applet*))
|
||||||
Q_PRIVATE_SLOT(d, void containmentAppletAnimationComplete(QGraphicsItem *item,
|
Q_PRIVATE_SLOT(d, void containmentAppletAnimationComplete(QGraphicsItem *item,
|
||||||
Plasma::Animator::Animation anim))
|
Plasma::Animator::Animation anim))
|
||||||
Q_PRIVATE_SLOT(d, void triggerShowAddWidgets())
|
Q_PRIVATE_SLOT(d, void triggerShowAddWidgets())
|
||||||
|
@ -75,7 +75,7 @@ public:
|
|||||||
void positionContainments();
|
void positionContainments();
|
||||||
void setLockToolText();
|
void setLockToolText();
|
||||||
void handleDisappeared(AppletHandle *handle);
|
void handleDisappeared(AppletHandle *handle);
|
||||||
void appletDestroyed(QObject*);
|
void appletDestroyed(Plasma::Applet*);
|
||||||
void containmentAppletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim);
|
void containmentAppletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim);
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
|
Loading…
Reference in New Issue
Block a user