rearrange the initialization code of the engines a bit, moving more out of the manager class, and calling init immediately. applets shouldn't be connecting to them in their ctor, so this should have minimal (or even zero) effect on start up while ensuring that init gets called first no matter what
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=779042
This commit is contained in:
parent
bc5accafd2
commit
507a6f02a0
@ -40,18 +40,26 @@ class DataEngine::Private
|
|||||||
public:
|
public:
|
||||||
Private(DataEngine* e, KService::Ptr service)
|
Private(DataEngine* e, KService::Ptr service)
|
||||||
: engine(e),
|
: engine(e),
|
||||||
ref(0),
|
ref(-1), // first ref
|
||||||
updateTimerId(0),
|
updateTimerId(0),
|
||||||
minUpdateInterval(-1),
|
minUpdateInterval(-1),
|
||||||
limit(0),
|
limit(0),
|
||||||
valid(true),
|
valid(true),
|
||||||
script(0),
|
script(0)
|
||||||
dataEngineDescription(service)
|
|
||||||
{
|
{
|
||||||
updateTimer = new QTimer(engine);
|
updateTimer = new QTimer(engine);
|
||||||
updateTimer->setSingleShot(true);
|
updateTimer->setSingleShot(true);
|
||||||
updateTimestamp.start();
|
updateTimestamp.start();
|
||||||
|
|
||||||
|
if (!service) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
engineName = service->property("X-Plasma-EngineName").toString();
|
||||||
|
e->setObjectName(engineName);
|
||||||
|
icon = service->icon();
|
||||||
|
|
||||||
|
KPluginInfo dataEngineDescription(service);
|
||||||
if (dataEngineDescription.isValid()) {
|
if (dataEngineDescription.isValid()) {
|
||||||
QString language = dataEngineDescription.property("X-Plasma-Language").toString();
|
QString language = dataEngineDescription.property("X-Plasma-Language").toString();
|
||||||
|
|
||||||
@ -185,18 +193,16 @@ class DataEngine::Private
|
|||||||
uint limit;
|
uint limit;
|
||||||
bool valid;
|
bool valid;
|
||||||
DataEngineScript* script;
|
DataEngineScript* script;
|
||||||
KPluginInfo dataEngineDescription;
|
QString engineName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DataEngine::DataEngine(QObject* parent, const QString& serviceId)
|
DataEngine::DataEngine(QObject* parent, KService::Ptr service)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new Private(this, KService::serviceByStorageId(serviceId)))
|
d(new Private(this, service))
|
||||||
{
|
{
|
||||||
connect(d->updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
|
connect(d->updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
|
||||||
//FIXME: we should delay this call; to when is the question.
|
init();
|
||||||
//Update DataEngine::init() api docu when fixed
|
|
||||||
QTimer::singleShot(0, this, SLOT(startInit()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine::DataEngine(QObject* parent, const QVariantList& args)
|
DataEngine::DataEngine(QObject* parent, const QVariantList& args)
|
||||||
@ -204,9 +210,7 @@ DataEngine::DataEngine(QObject* parent, const QVariantList& args)
|
|||||||
d(new Private(this, KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString())))
|
d(new Private(this, KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString())))
|
||||||
{
|
{
|
||||||
connect(d->updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
|
connect(d->updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
|
||||||
//FIXME: we should delay this call; to when is the question.
|
init();
|
||||||
//Update DataEngine::init() api docu when fixed
|
|
||||||
QTimer::singleShot(0, this, SLOT(startInit()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine::~DataEngine()
|
DataEngine::~DataEngine()
|
||||||
@ -271,11 +275,6 @@ DataEngine::Data DataEngine::query(const QString& source) const
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::startInit()
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::internalUpdateSource(DataContainer* source)
|
void DataEngine::internalUpdateSource(DataContainer* source)
|
||||||
{
|
{
|
||||||
if (d->minUpdateInterval > 0 &&
|
if (d->minUpdateInterval > 0 &&
|
||||||
@ -529,11 +528,7 @@ void DataEngine::checkForUpdates()
|
|||||||
|
|
||||||
QString DataEngine::engineName() const
|
QString DataEngine::engineName() const
|
||||||
{
|
{
|
||||||
if (!d->dataEngineDescription.isValid()) {
|
return d->engineName;
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return d->dataEngineDescription.property("X-Plasma-EngineName").toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
13
dataengine.h
13
dataengine.h
@ -24,7 +24,8 @@
|
|||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
#include <kgenericfactory.h>
|
#include <KGenericFactory>
|
||||||
|
#include <KService>
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
#include <plasma/plasma.h>
|
#include <plasma/plasma.h>
|
||||||
@ -64,11 +65,12 @@ class PLASMA_EXPORT DataEngine : public QObject
|
|||||||
typedef QHash<QString, DataContainer*> SourceDict;
|
typedef QHash<QString, DataContainer*> SourceDict;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param parent The parent object.
|
* @param parent The parent object.
|
||||||
|
* @param service pointer to the service that describes the engine
|
||||||
**/
|
**/
|
||||||
explicit DataEngine(QObject* parent = 0, const QString& serviceId = QString());
|
explicit DataEngine(QObject* parent = 0, KService::Ptr service = KService::Ptr(0));
|
||||||
DataEngine(QObject* parent, const QVariantList& args);
|
DataEngine(QObject* parent, const QVariantList& args);
|
||||||
virtual ~DataEngine();
|
virtual ~DataEngine();
|
||||||
|
|
||||||
@ -395,11 +397,6 @@ class PLASMA_EXPORT DataEngine : public QObject
|
|||||||
**/
|
**/
|
||||||
void removeSource(const QString& source);
|
void removeSource(const QString& source);
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
**/
|
|
||||||
void startInit();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
**/
|
**/
|
||||||
|
@ -130,7 +130,7 @@ Plasma::DataEngine* DataEngineManager::loadDataEngine(const QString& name)
|
|||||||
if (language.isEmpty()) {
|
if (language.isEmpty()) {
|
||||||
engine = offers.first()->createInstance<Plasma::DataEngine>(0, allArgs, &error);
|
engine = offers.first()->createInstance<Plasma::DataEngine>(0, allArgs, &error);
|
||||||
} else {
|
} else {
|
||||||
engine = new DataEngine(0, offers.first()->storageId());
|
engine = new DataEngine(0, offers.first());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,9 +139,6 @@ Plasma::DataEngine* DataEngineManager::loadDataEngine(const QString& name)
|
|||||||
return d->nullEngine();
|
return d->nullEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
engine->ref();
|
|
||||||
engine->setObjectName(offers.first()->name());
|
|
||||||
engine->setIcon(offers.first()->icon());
|
|
||||||
d->engines[name] = engine;
|
d->engines[name] = engine;
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user