Commit 7b46ed8d authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas
Browse files

the objectManagerTest no longer fails.

parent 851636b8
......@@ -67,6 +67,7 @@ set(${PROJECT_NAME}_SOURCES
dtkCoreSettings.cpp
dtkArrayData.cpp
dtkCoreLayerManager.cpp
dtkCorePluginFactory.cpp
dtkCorePluginManagerHandler.cpp
dtkCorePluginManagerRecorder.cpp
dtkObjectManager.cpp)
......
......@@ -17,7 +17,7 @@
The QVariant is defined by the QMetaType \a type and the address of the object \a t.
*/
void dtkCorePluginFactoryBase::touch(int type, void *t)
void dtkCorePluginFactoryBase::touch(int type, void *t) const
{
emit created(QVariant(type, t));
}
......
......@@ -28,10 +28,10 @@ class DTKCORE_EXPORT dtkCorePluginFactoryBase : public QObject
Q_OBJECT
signals:
void created(const QVariant&);
void created(const QVariant&) const;
protected:
void touch(int type, void *t);
void touch(int type, void *t) const;
};
// ///////////////////////////////////////////////////////////////////
......@@ -61,9 +61,6 @@ public:
public:
QStringList keys(void) const;
public:
void touch(T *t);
private:
QHash<QString, creator> creators;
QHash<QString, tunerCreator> tuner_creators;
......
......@@ -65,7 +65,11 @@ template <typename T> T *dtkCorePluginFactory<T>::create(const QString& key) con
if (!this->creators.contains(key))
return NULL;
return this->creators.value(key)();
T *obj = this->creators.value(key)();
if (obj)
this->dtkCorePluginFactoryBase::touch(qMetaTypeId<T *>(), obj);
return obj;
}
template <typename T> dtkCorePluginTuner<T> *dtkCorePluginFactory<T>::createTuner(const QString& key) const
......@@ -76,14 +80,6 @@ template <typename T> dtkCorePluginTuner<T> *dtkCorePluginFactory<T>::createTune
return this->tuner_creators.value(key)();
}
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
template <typename T> void dtkCorePluginFactory<T>::touch(T *t)
{
this->dtkCorePluginFactoryBase::touch(qMetaTypeId<T *>(), t);
}
// /////////////////////////////////////////////////////////////////
// Type creator inspection
......
......@@ -35,13 +35,14 @@ dtkObjectManagerTestCase::~dtkObjectManagerTestCase(void)
void dtkObjectManagerTestCase::initTestCase(void)
{
connect(&dtkDistributed::communicator::pluginManager(), SIGNAL(created(const QVariant&)), dtkObjectManager::instance(), SLOT(add(const QVariant&)));
connect(&dtkDistributed::communicator::pluginFactory(), SIGNAL(created(const QVariant&)), dtkObjectManager::instance(), SLOT(add(const QVariant&)));
dtkDistributed::communicator::initialize();
dtkDistributedCommunicator *communicator_1 = dtkDistributed::communicator::pluginFactory().create("qthread");
dtkDistributedCommunicator *communicator_2 = dtkDistributed::communicator::pluginFactory().create("qthread");
Q_UNUSED(communicator_1);
Q_UNUSED(communicator_2);
QVERIFY(communicator_1 != nullptr);
QVERIFY(communicator_2 != nullptr);
}
void dtkObjectManagerTestCase::init(void)
......@@ -51,7 +52,7 @@ void dtkObjectManagerTestCase::init(void)
void dtkObjectManagerTestCase::testCount(void)
{
QVERIFY(dtkObjectManager::instance()->count() == 2);
QCOMPARE(dtkObjectManager::instance()->count() , 2);
}
void dtkObjectManagerTestCase::cleanup(void)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment