move the call to init() out of ctor and call it immediately after construction; that way the vtable can be set up and we'll get the virtual called in the subclass

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=782820
This commit is contained in:
Aaron J. Seigo 2008-03-06 05:18:36 +00:00
parent 5c2a3635f4
commit a234d1b6c3
3 changed files with 10 additions and 11 deletions

View File

@ -202,7 +202,6 @@ DataEngine::DataEngine(QObject* parent, KService::Ptr service)
d(new Private(this, service))
{
connect(d->updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
init();
}
DataEngine::DataEngine(QObject* parent, const QVariantList& args)
@ -210,7 +209,6 @@ DataEngine::DataEngine(QObject* parent, const QVariantList& args)
d(new Private(this, KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString())))
{
connect(d->updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
init();
}
DataEngine::~DataEngine()
@ -298,7 +296,7 @@ void DataEngine::init()
if (d->script) {
d->script->init();
} else {
// kDebug() << "DataEngine::init() called ";
// kDebug() << "called";
// default implementation does nothing. this is for engines that have to
// start things in motion external to themselves before they can work
}

View File

@ -74,6 +74,14 @@ class PLASMA_EXPORT DataEngine : public QObject
DataEngine(QObject* parent, const QVariantList& args);
virtual ~DataEngine();
/**
* This method is called when the DataEngine is started. When this
* method is called the DataEngine is fully constructed and ready to be
* used. This method should be reimplemented by DataEngine subclasses
* which have the need to perform a startup routine.
**/
virtual void init();
/**
* @return a list of all the data sources available via this DataEngine
* Whether these sources are currently available (which is what
@ -222,14 +230,6 @@ class PLASMA_EXPORT DataEngine : public QObject
void sourceRemoved(const QString& source);
protected:
/**
* This method is called when the DataEngine is started. When this
* method is called the DataEngine is fully constructed and ready to be
* used. This method should be reimplemented by DataEngine subclasses
* which have the need to perform a startup routine.
**/
virtual void init();
/**
* When a source that does not currently exist is requested by the
* consumer, this method is called to give the DataEngine the

View File

@ -139,6 +139,7 @@ Plasma::DataEngine* DataEngineManager::load(const QString& name)
return d->nullEngine();
}
engine->init();
d->engines[name] = engine;
return engine;
}