Fix a rare bug when a new applet handle is created before the previous one is
destroyed, causing the applet not to follow the handle when moved or fail to appear. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=849828
This commit is contained in:
parent
bacc1d65d4
commit
b7e61e34c4
@ -1311,6 +1311,7 @@ void ContainmentPrivate::handleDisappeared(AppletHandle *handle)
|
||||
{
|
||||
if (handles.contains(handle->applet())) {
|
||||
handles.remove(handle->applet());
|
||||
handle->detachApplet();
|
||||
handle->deleteLater();
|
||||
}
|
||||
}
|
||||
|
@ -121,27 +121,7 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
|
||||
|
||||
AppletHandle::~AppletHandle()
|
||||
{
|
||||
if (m_applet) {
|
||||
m_applet->removeSceneEventFilter(this);
|
||||
|
||||
QRectF rect = QRectF(m_applet->pos(), m_applet->size());
|
||||
QPointF center = m_applet->mapFromParent(rect.center());
|
||||
|
||||
QPointF newPos = transform().inverted().map(m_applet->pos());
|
||||
m_applet->setPos(mapToParent(newPos));
|
||||
|
||||
QTransform matrix;
|
||||
matrix.translate(center.x(), center.y());
|
||||
matrix.rotateRadians(m_angle);
|
||||
matrix.translate(-center.x(), -center.y());
|
||||
m_applet->setTransform(matrix);
|
||||
|
||||
m_applet->setParentItem(m_containment);
|
||||
|
||||
m_applet->setZValue(m_zValue);
|
||||
|
||||
m_applet->update(); // re-render the background, now we've transformed the applet
|
||||
}
|
||||
detachApplet();
|
||||
if (m_topview) {
|
||||
delete m_topview;
|
||||
}
|
||||
@ -152,6 +132,39 @@ Applet *AppletHandle::applet() const
|
||||
return m_applet;
|
||||
}
|
||||
|
||||
void AppletHandle::detachApplet ()
|
||||
{
|
||||
if (!m_applet) {
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect(m_hoverTimer, SIGNAL(timeout()), this, SLOT(fadeIn()));
|
||||
disconnect(m_leaveTimer, SIGNAL(timeout()), this, SLOT(leaveTimeout()));
|
||||
m_applet->disconnect(this);
|
||||
|
||||
m_applet->removeSceneEventFilter(this);
|
||||
|
||||
QRectF rect = QRectF(m_applet->pos(), m_applet->size());
|
||||
QPointF center = m_applet->mapFromParent(rect.center());
|
||||
|
||||
QPointF newPos = transform().inverted().map(m_applet->pos());
|
||||
m_applet->setPos(mapToParent(newPos));
|
||||
|
||||
QTransform matrix;
|
||||
matrix.translate(center.x(), center.y());
|
||||
matrix.rotateRadians(m_angle);
|
||||
matrix.translate(-center.x(), -center.y());
|
||||
m_applet->setTransform(matrix);
|
||||
|
||||
m_applet->setParentItem(m_containment);
|
||||
|
||||
m_applet->setZValue(m_zValue);
|
||||
|
||||
m_applet->update(); // re-render the background, now we've transformed the applet
|
||||
|
||||
m_applet = 0;
|
||||
}
|
||||
|
||||
QRectF Plasma::AppletHandle::boundingRect() const
|
||||
{
|
||||
return m_totalRect;
|
||||
@ -715,12 +728,13 @@ void AppletHandle::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
Q_UNUSED(event);
|
||||
//kDebug() << "hover enter";
|
||||
|
||||
//if a disappear was scheduled stop the timer
|
||||
m_leaveTimer->stop();
|
||||
|
||||
// if we're already fading out, fade back in
|
||||
if (m_animId != 0) {
|
||||
if (m_animId != 0 && m_anim == FadeOut) {
|
||||
startFading(FadeIn, m_entryPos);
|
||||
} else {
|
||||
//if a disappear was scheduled stop the timer
|
||||
m_leaveTimer->stop();
|
||||
//schedule appear
|
||||
m_hoverTimer->start();
|
||||
}
|
||||
@ -759,6 +773,9 @@ void AppletHandle::fadeAnimation(qreal progress)
|
||||
qreal endOpacity = (m_anim == FadeIn) ? 1.0 : 0.0;
|
||||
m_opacity += (endOpacity - m_opacity) * progress;
|
||||
//kDebug() << "progress" << progress << "m_opacity" << m_opacity << endOpacity;
|
||||
if (progress >= 1.0) {
|
||||
m_animId = 0;
|
||||
}
|
||||
if (progress >= 1.0 && m_anim == FadeOut) {
|
||||
emit disappearDone(this);
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ class AppletHandle : public QObject, public QGraphicsItem
|
||||
AppletHandle(Containment *parent, Applet *applet, const QPointF &hoverPos);
|
||||
virtual ~AppletHandle();
|
||||
|
||||
void detachApplet ();
|
||||
|
||||
Applet *applet() const;
|
||||
|
||||
QRectF boundingRect() const;
|
||||
|
Loading…
Reference in New Issue
Block a user