[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.5/kdebase/workspace/plasma/desktop/shell/activitymanager
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2010-09-11 1:14:17
Message-ID: 20100911011417.72691AC888 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1173981 by aseigo:
don't crash when removing activities: ActivityIcon was calling destroy on the \
Activity object in its mouse event, which can then lead to a quick (and crash \
inducing) deletion of the item while it is still in its mouse event. so we take two \
precautions: call destroy using a single shot timer, and clear the Activity* in \
ActivityIcon when it is removed
M +19 -2 activityicon.cpp
M +1 -0 activityicon.h
M +5 -2 activitylist.cpp
--- branches/KDE/4.5/kdebase/workspace/plasma/desktop/shell/activitymanager/activityicon.cpp \
#1173980:1173981 @@ -52,7 +52,7 @@
QPixmap ActivityIcon::pixmap(const QSize &size)
{
- return m_activity->pixmap(size);
+ return m_activity ? m_activity->pixmap(size) : QPixmap();
}
QMimeData* ActivityIcon::mimeData()
@@ -65,6 +65,10 @@
{
AbstractIcon::paint(painter, option, widget);
+ if (!m_activity) {
+ return;
+ }
+
const QRectF rect = contentsRect();
QSize cornerIconSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
qreal iconX = rect.x() + qMax<double>(0.0, (rect.width() - iconSize()) / 2.0); \
//icon's centered @@ -95,6 +99,10 @@
void ActivityIcon::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
+ if (!m_activity) {
+ return;
+ }
+
//check whether one of our corner icons was clicked
//FIXME this is duplicate code, should get cleaned up later
const QRectF rect = contentsRect();
@@ -108,7 +116,7 @@
if (m_activity->isRunning()) {
m_activity->close();
} else {
- m_activity->destroy();
+ QTimer::singleShot(0, m_activity, SLOT(destroy()));
}
return;
}
@@ -126,6 +134,7 @@
if (removable == m_removable) {
return;
}
+
m_removable = removable;
update();
}
@@ -135,3 +144,11 @@
return m_activity;
}
+void ActivityIcon::activityRemoved()
+{
+ m_activity = 0;
+ deleteLater();
+}
+
+#include "activityicon.moc"
+
--- branches/KDE/4.5/kdebase/workspace/plasma/desktop/shell/activitymanager/activityicon.h \
#1173980:1173981 @@ -36,6 +36,7 @@
void setRemovable(bool removable);
Activity* activity();
+ void activityRemoved();
QPixmap pixmap(const QSize &size);
QMimeData* mimeData();
--- branches/KDE/4.5/kdebase/workspace/plasma/desktop/shell/activitymanager/activitylist.cpp \
#1173980:1173981 @@ -101,8 +101,11 @@
void ActivityList::activityRemoved(const QString &id)
{
- Plasma::AbstractIcon* icon = m_allAppletsHash.take(id);
- delete icon;
+ ActivityIcon *icon = qobject_cast<ActivityIcon *>(m_allAppletsHash.take(id));
+
+ if (icon) {
+ icon->activityRemoved();
+ }
/*
if (m_allAppletsHash.count() == 1) {
ActivityIcon *icon = \
qobject_cast<ActivityIcon*>(m_allAppletsHash.values().first());
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic