[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/libs/taskmanager
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2010-09-26 19:13:22
Message-ID: 20100926191322.04658AC857 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1180012 by aseigo:
* move some slots to the private class
* delay the signalling from the group that items have been removed; this allows the \
items to fully delete, preventing possible usage of the item object when it is only \
half-destructed (and therefore a AbstractGroupableItem with pure virtuals)
a little too invasive to backport without more testing
BUG:252383
M +28 -9 taskgroup.cpp
M +4 -4 taskgroup.h
--- trunk/KDE/kdebase/workspace/libs/taskmanager/taskgroup.cpp #1180011:1180012
@@ -30,6 +30,7 @@
// Qt
#include <QtGui/QColor>
#include <QtCore/QMimeData>
+#include <QtCore/QTimer>
// KDE
#include <KDE/KDebug>
@@ -45,10 +46,17 @@
class TaskGroup::Private
{
public:
- Private()
+ Private(TaskGroup *group)
+ : q(group)
{
}
+ void itemDestroyed(AbstractGroupableItem *item);
+ void itemChanged(::TaskManager::TaskChanges changes);
+ void signalRemovals();
+
+ TaskGroup *q;
+ QList<AbstractGroupableItem *> signalRemovalsFor;
ItemList members;
QList<LauncherItem*> invisibleLaunchers;
QString groupName;
@@ -61,7 +69,7 @@
TaskGroup::TaskGroup(GroupManager *parent,const QString &name, const QColor &color)
: AbstractGroupableItem(parent),
- d(new Private)
+ d(new Private(this))
{
d->groupingStrategy = parent;
d->groupName = name;
@@ -74,7 +82,7 @@
TaskGroup::TaskGroup(GroupManager *parent)
: AbstractGroupableItem(parent),
- d(new Private)
+ d(new Private(this))
{
d->groupingStrategy = parent;
// d->groupName = "default";
@@ -213,20 +221,31 @@
emit itemAdded(item);
}
-void TaskGroup::itemDestroyed(AbstractGroupableItem *item)
+void TaskGroup::Private::itemDestroyed(AbstractGroupableItem *item)
{
- d->members.removeAll(item);
- emit itemRemoved(item);
+ members.removeAll(item);
+ signalRemovalsFor << item;
+ QTimer::singleShot(0, q, SLOT(signalRemovals()));
}
-void TaskGroup::itemChanged(::TaskManager::TaskChanges changes)
+void TaskGroup::Private::signalRemovals()
{
+ // signal removals for is full of dangling pointers. do not use them!
+ foreach (AbstractGroupableItem *item, signalRemovalsFor) {
+ emit q->itemRemoved(item);
+ }
+
+ signalRemovalsFor.clear();
+}
+
+void TaskGroup::Private::itemChanged(::TaskManager::TaskChanges changes)
+{
if (changes & ::TaskManager::IconChanged) {
- emit checkIcon(this);
+ emit q->checkIcon(q);
}
if (changes & StateChanged) {
- emit changed(StateChanged);
+ emit q->changed(StateChanged);
}
}
--- trunk/KDE/kdebase/workspace/libs/taskmanager/taskgroup.h #1180011:1180012
@@ -146,11 +146,11 @@
void movedToDesktop(int newDesk);
void checkIcon(TaskGroup *group);
-private Q_SLOTS:
- void itemDestroyed(AbstractGroupableItem *item);
- void itemChanged(::TaskManager::TaskChanges changes);
+private:
+ Q_PRIVATE_SLOT(d, void itemDestroyed(AbstractGroupableItem *item))
+ Q_PRIVATE_SLOT(d, void itemChanged(::TaskManager::TaskChanges changes))
+ Q_PRIVATE_SLOT(d, void signalRemovals())
-private:
class Private;
Private * const d;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic