From a234d1b6c372b7f61cefdf9a635aa0a8262f6849 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 6 Mar 2008 05:18:36 +0000 Subject: [PATCH] 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 --- dataengine.cpp | 4 +--- dataengine.h | 16 ++++++++-------- dataenginemanager.cpp | 1 + 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dataengine.cpp b/dataengine.cpp index db912dd41..b5f18db9e 100644 --- a/dataengine.cpp +++ b/dataengine.cpp @@ -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 } diff --git a/dataengine.h b/dataengine.h index 9f032b0ae..b89402a01 100644 --- a/dataengine.h +++ b/dataengine.h @@ -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 diff --git a/dataenginemanager.cpp b/dataenginemanager.cpp index a9e4acbe3..98d9c2744 100644 --- a/dataenginemanager.cpp +++ b/dataenginemanager.cpp @@ -139,6 +139,7 @@ Plasma::DataEngine* DataEngineManager::load(const QString& name) return d->nullEngine(); } + engine->init(); d->engines[name] = engine; return engine; }