clean up from the sources if somebody deletes a DataContainer
BUG:235881 svn path=/trunk/KDE/kdelibs/; revision=1136398
This commit is contained in:
parent
85d9343669
commit
3e3fd09aab
@ -251,6 +251,7 @@ void DataEngine::addSource(DataContainer *source)
|
||||
|
||||
QObject::connect(source, SIGNAL(updateRequested(DataContainer*)),
|
||||
this, SLOT(internalUpdateSource(DataContainer*)));
|
||||
QObject::connect(source, SIGNAL(destroyed()), this, SLOT(sourceDestroyed()));
|
||||
d->sources.insert(source->objectName(), source);
|
||||
emit sourceAdded(source->objectName());
|
||||
scheduleSourcesUpdated();
|
||||
@ -620,6 +621,7 @@ DataContainer *DataEnginePrivate::source(const QString &sourceName, bool createW
|
||||
DataContainer *s = new DataContainer(q);
|
||||
s->setObjectName(sourceName);
|
||||
sources.insert(sourceName, s);
|
||||
QObject::connect(s, SIGNAL(destroyed(QObject *)), q, SLOT(sourceDestroyed(QObject *)));
|
||||
QObject::connect(s, SIGNAL(updateRequested(DataContainer*)),
|
||||
q, SLOT(internalUpdateSource(DataContainer*)));
|
||||
|
||||
@ -667,6 +669,20 @@ void DataEnginePrivate::connectSource(DataContainer *s, QObject *visualization,
|
||||
}
|
||||
}
|
||||
|
||||
void DataEnginePrivate::sourceDestroyed(QObject *object)
|
||||
{
|
||||
DataContainer *container = qobject_cast<DataContainer *>(object);
|
||||
|
||||
DataEngine::SourceDict::const_iterator it = sources.begin();
|
||||
while (it != sources.constEnd()) {
|
||||
if (it.value() == object) {
|
||||
sources.remove(it.key());
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
DataContainer *DataEnginePrivate::requestSource(const QString &sourceName, bool *newSource)
|
||||
{
|
||||
if (newSource) {
|
||||
|
@ -485,6 +485,7 @@ NoAlignment) const;
|
||||
friend class NullEngine;
|
||||
|
||||
Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer *source))
|
||||
Q_PRIVATE_SLOT(d, void sourceDestroyed(QObject *object));
|
||||
|
||||
DataEnginePrivate *const d;
|
||||
};
|
||||
|
@ -79,6 +79,11 @@ class DataEnginePrivate
|
||||
*/
|
||||
bool isPublished() const;
|
||||
|
||||
/**
|
||||
* a datacontainer has been destroyed, clean up stuff
|
||||
*/
|
||||
void sourceDestroyed(QObject *object);
|
||||
|
||||
DataEngine *q;
|
||||
KPluginInfo dataEngineDescription;
|
||||
int refCount;
|
||||
|
Loading…
Reference in New Issue
Block a user