From 9500388d8dd8bf2ef5f6fbe483fdc5092be0cf23 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 20 Oct 2009 01:28:02 +0000 Subject: [PATCH] don't crash when serviceForSource is called "too early" on a remote data engine svn path=/trunk/KDE/kdelibs/; revision=1037790 --- private/remotedataengine.cpp | 16 +++++++++++++++- private/remotedataengine.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/private/remotedataengine.cpp b/private/remotedataengine.cpp index ef9515311..dd9414982 100644 --- a/private/remotedataengine.cpp +++ b/private/remotedataengine.cpp @@ -69,10 +69,17 @@ Plasma::Service* RemoteDataEngine::serviceForSource(const QString& source) } else { RemoteService *service = new RemoteService(this); m_serviceForSource[source] = service; + initRemoteService(source, service); + return service; + } +} + +void RemoteDataEngine::initRemoteService(const QString &source, RemoteService *service) +{ + if (m_service) { KConfigGroup op = m_service->operationDescription("ServiceForSource"); op.writeEntry("SourceName", source); m_service->startOperationCall(op); - return service; } } @@ -83,6 +90,13 @@ void RemoteDataEngine::init() void RemoteDataEngine::serviceReady(Plasma::Service *service) { m_service = service; + + QMapIterator it(m_serviceForSource); + while (it.hasNext()) { + it.next(); + initRemoteService(it.key(), it.value()); + } + KConfigGroup op = m_service->operationDescription("GetSourceNames"); m_service->startOperationCall(op); connect(m_service, SIGNAL(finished(Plasma::ServiceJob*)), diff --git a/private/remotedataengine.h b/private/remotedataengine.h index 96adab678..06329624f 100644 --- a/private/remotedataengine.h +++ b/private/remotedataengine.h @@ -49,6 +49,7 @@ private Q_SLOTS: void serviceReady(Plasma::Service *service); void remoteCallFinished(Plasma::ServiceJob *job); void updateSources(); + void initRemoteService(const QString &source, RemoteService *service); private: Service *m_service;