diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/aspects/qabstractaspect.h | 2 | ||||
-rw-r--r-- | src/core/aspects/qaspectengine.cpp | 20 | ||||
-rw-r--r-- | src/core/aspects/qaspectengine.h | 1 | ||||
-rw-r--r-- | src/core/aspects/qaspectmanager.cpp | 17 | ||||
-rw-r--r-- | src/core/aspects/qaspectmanager_p.h | 2 |
5 files changed, 8 insertions, 34 deletions
diff --git a/src/core/aspects/qabstractaspect.h b/src/core/aspects/qabstractaspect.h index e5842aa08..aa3404f1c 100644 --- a/src/core/aspects/qabstractaspect.h +++ b/src/core/aspects/qabstractaspect.h @@ -75,7 +75,7 @@ private: virtual QVector<QAspectJobPtr> jobsToExecute(qint64 time) = 0; - virtual void onInitialize(const QVariantMap &data) = 0; + virtual void onInitialize() = 0; virtual void onCleanup() = 0; virtual void onStartup(); diff --git a/src/core/aspects/qaspectengine.cpp b/src/core/aspects/qaspectengine.cpp index 3aa2b0f95..7eb26e1d6 100644 --- a/src/core/aspects/qaspectengine.cpp +++ b/src/core/aspects/qaspectengine.cpp @@ -165,27 +165,16 @@ void QAspectEnginePrivate::shutdown() qCDebug(Aspects) << Q_FUNC_INFO << "Shutdown complete"; } -// Main thread -void QAspectEngine::setData(const QVariantMap &data) -{ - Q_D(QAspectEngine); - // Note: setData in the AspectManager is called in the main thread - // which in turns calls onInitialize on each aspects in the main thread - // We should keep the call to onInitialize in the main thread - QMetaObject::invokeMethod(d->m_aspectThread->aspectManager(), - "setData", - Qt::BlockingQueuedConnection, - Q_ARG(const QVariantMap &, data)); -} - /*! * Registers a new \a aspect to the AspectManager. - * Passing as a QObject* as abstracts like AbstractAspect - * cannot be registered as a meta type. */ void QAspectEngine::registerAspect(QAbstractAspect *aspect) { Q_D(QAspectEngine); + // The aspect is moved to the AspectThread + // AspectManager::registerAspect is called in the context + // of the AspectThread. This is turns call aspect->onInitialize + // still in the same AspectThread context aspect->moveToThread(d->m_aspectThread); d->m_aspects << aspect; QMetaObject::invokeMethod(d->m_aspectThread->aspectManager(), @@ -265,6 +254,7 @@ void QAspectEngine::setRootEntity(QEntity *root) if (!d->m_root) return; + // Set postman/scene/arbiter ... d->initialize(); // The aspect engine takes ownership of the scene root. We also set the diff --git a/src/core/aspects/qaspectengine.h b/src/core/aspects/qaspectengine.h index b472e4130..bc9ee1bc6 100644 --- a/src/core/aspects/qaspectengine.h +++ b/src/core/aspects/qaspectengine.h @@ -62,7 +62,6 @@ public: void setRootEntity(QEntity *root); QSharedPointer<QEntity> rootEntity() const; - void setData(const QVariantMap &data); void registerAspect(QAbstractAspect *aspect); void registerAspect(const QString &name); diff --git a/src/core/aspects/qaspectmanager.cpp b/src/core/aspects/qaspectmanager.cpp index 80faef768..01441df53 100644 --- a/src/core/aspects/qaspectmanager.cpp +++ b/src/core/aspects/qaspectmanager.cpp @@ -130,15 +130,6 @@ void QAspectManager::setRootEntity(Qt3DCore::QEntity *root) } } -// Should be called after aspects are registered -void QAspectManager::setData(const QVariantMap &data) -{ - qCDebug(Aspects) << Q_FUNC_INFO; - m_data = data; - Q_FOREACH (QAbstractAspect *aspect, m_aspects) - aspect->onInitialize(m_data); -} - /*! * Registers a new \a aspect. */ @@ -153,7 +144,8 @@ void QAspectManager::registerAspect(QAbstractAspect *aspect) QAbstractAspectPrivate::get(aspect)->m_arbiter = m_changeArbiter; // Register sceneObserver with the QChangeArbiter m_changeArbiter->registerSceneObserver(aspect->d_func()); - aspect->onInitialize(m_data); + // Initialize the aspect in the main thread + aspect->onInitialize(); } else { qCWarning(Aspects) << "Failed to register aspect"; @@ -161,11 +153,6 @@ void QAspectManager::registerAspect(QAbstractAspect *aspect) qCDebug(Aspects) << "Completed registering aspect"; } -QVariantMap QAspectManager::data() const -{ - return m_data; -} - void QAspectManager::exec() { // Gentlemen, start your engines diff --git a/src/core/aspects/qaspectmanager_p.h b/src/core/aspects/qaspectmanager_p.h index 88ceceb29..cc3b91fff 100644 --- a/src/core/aspects/qaspectmanager_p.h +++ b/src/core/aspects/qaspectmanager_p.h @@ -84,9 +84,7 @@ public Q_SLOTS: void shutdown(); void setRootEntity(Qt3DCore::QEntity *root); - void setData(const QVariantMap &data); void registerAspect(Qt3DCore::QAbstractAspect *aspect); - QVariantMap data() const; void exec(); void quit(); |