From 423ce0c3564c3b81ed9266556c4fe558ee511bf2 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Thu, 1 Sep 2011 19:07:22 +0200 Subject: [PATCH] don't emit addSource for a source being added in a sourceRequest event until the event is over --- dataengine.cpp | 7 +++++-- private/dataengine_p.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dataengine.cpp b/dataengine.cpp index 7be42f9d3..5993942c1 100644 --- a/dataengine.cpp +++ b/dataengine.cpp @@ -197,7 +197,7 @@ void DataEngine::setData(const QString &source, const QString &key, const QVaria s->setData(key, value); - if (isNew) { + if (isNew && source != d->waitingSourceRequest) { emit sourceAdded(source); } @@ -219,7 +219,7 @@ void DataEngine::setData(const QString &source, const Data &data) ++it; } - if (isNew) { + if (isNew && source != d->waitingSourceRequest) { emit sourceAdded(source); } @@ -701,6 +701,7 @@ DataContainer *DataEnginePrivate::requestSource(const QString &sourceName, bool /*kDebug() << "DataEngine " << q->objectName() << ": could not find DataContainer " << sourceName << " will create on request" << endl;*/ + waitingSourceRequest = sourceName; if (q->sourceRequestEvent(sourceName)) { s = source(sourceName, false); if (s) { @@ -710,8 +711,10 @@ DataContainer *DataEnginePrivate::requestSource(const QString &sourceName, bool *newSource = true; } QObject::connect(s, SIGNAL(becameUnused(QString)), q, SLOT(removeSource(QString))); + emit q->sourceAdded(sourceName); } } + waitingSourceRequest.clear(); } return s; diff --git a/private/dataengine_p.h b/private/dataengine_p.h index 302b6057c..74a61e221 100644 --- a/private/dataengine_p.h +++ b/private/dataengine_p.h @@ -118,6 +118,7 @@ class DataEnginePrivate QString serviceName; Package *package; Service *publishedService; + QString waitingSourceRequest; }; } // Plasma namespace