diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2017-02-09 09:24:52 +0100 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2017-02-14 09:23:08 +0000 |
commit | 569b3e6f2b651bc899e31fd4a522aa4d6aeae968 (patch) | |
tree | 361508f6895c9a447325c74dbc8a3c4353f00800 | |
parent | 32f6315d6d458600bb3f1db08c53148557382c21 (diff) |
Replace usage of QSignalMapper by lambda
QSignalMapper ought to be deprecated soon.
It simplifies the code, too.
There is still one use in QQuickGenericShaderEffect which is a bit complicated
to get rid of. A very similar use of QSignalMapper was in use in
QQuickOpenGLShaderEffectCommon but was removed in commit 8c745d80, the same
should be done for QQuickGenericShaderEffect.
(Note the QueuedConnection in qquickparticlesystem is there because the
QSignalMapper used to be in the main thread, meaning a round-trip via the
event loop)
Change-Id: I331b787becbad37f717035bf119bafd7a7214630
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
-rw-r--r-- | src/particles/qquickcustomparticle_p.h | 1 | ||||
-rw-r--r-- | src/particles/qquickparticlesystem.cpp | 13 | ||||
-rw-r--r-- | src/particles/qquickparticlesystem_p.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.cpp | 13 | ||||
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.h | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmlapplicationengine_p.h | 4 | ||||
-rw-r--r-- | src/quick/items/qquickopenglshadereffect_p.h | 1 |
7 files changed, 9 insertions, 29 deletions
diff --git a/src/particles/qquickcustomparticle_p.h b/src/particles/qquickcustomparticle_p.h index 1d48786a41..e2292cb33b 100644 --- a/src/particles/qquickcustomparticle_p.h +++ b/src/particles/qquickcustomparticle_p.h @@ -53,7 +53,6 @@ #include "qquickparticlepainter_p.h" #include <private/qquickopenglshadereffectnode_p.h> #include <private/qquickopenglshadereffect_p.h> -#include <QSignalMapper> QT_BEGIN_NAMESPACE diff --git a/src/particles/qquickparticlesystem.cpp b/src/particles/qquickparticlesystem.cpp index b60180b2ed..99e278238b 100644 --- a/src/particles/qquickparticlesystem.cpp +++ b/src/particles/qquickparticlesystem.cpp @@ -575,9 +575,6 @@ QQuickParticleSystem::QQuickParticleSystem(QQuickItem *parent) : m_paused(false), m_empty(true) { - connect(&m_painterMapper, SIGNAL(mapped(QObject*)), - this, SLOT(loadPainter(QObject*))); - m_debugMode = qmlParticlesDebug(); } @@ -615,8 +612,8 @@ void QQuickParticleSystem::registerParticlePainter(QQuickParticlePainter* p) qDebug() << "Registering Painter" << p << "to" << this; //TODO: a way to Unregister emitters, painters and affectors m_painters << QPointer<QQuickParticlePainter>(p);//###Set or uniqueness checking? - connect(p, SIGNAL(groupsChanged(QStringList)), - &m_painterMapper, SLOT(map())); + + connect(p, &QQuickParticlePainter::groupsChanged, this, [this, p] { this->loadPainter(p); }, Qt::QueuedConnection); loadPainter(p); } @@ -802,13 +799,11 @@ void QQuickParticleSystem::reset() } -void QQuickParticleSystem::loadPainter(QObject *p) +void QQuickParticleSystem::loadPainter(QQuickParticlePainter *painter) { - if (!m_componentComplete || !p) + if (!m_componentComplete || !painter) return; - QQuickParticlePainter* painter = qobject_cast<QQuickParticlePainter*>(p); - Q_ASSERT(painter);//XXX for (QQuickParticleGroupData* sg : groupData) { sg->painters.removeOne(painter); } diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h index de39b436e2..92dca40419 100644 --- a/src/particles/qquickparticlesystem_p.h +++ b/src/particles/qquickparticlesystem_p.h @@ -56,7 +56,6 @@ #include <QVector> #include <QHash> #include <QPointer> -#include <QSignalMapper> #include <private/qquicksprite_p.h> #include <QAbstractAnimation> #include <QtQml/qqml.h> @@ -393,7 +392,7 @@ protected: private Q_SLOTS: void emittersChanged(); - void loadPainter(QObject* p); + void loadPainter(QQuickParticlePainter *p); void createEngine(); //Not invoked by sprite engine, unlike Sprite uses void particleStateChange(int idx); @@ -461,8 +460,6 @@ private: QSet<int> m_reusableIndexes; bool m_componentComplete; - QSignalMapper m_painterMapper; - QSignalMapper m_emitterMapper; bool m_paused; bool m_allDead; bool m_empty; diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index 2a96d96302..a10dda166c 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -66,8 +66,6 @@ void QQmlApplicationEnginePrivate::cleanUp() void QQmlApplicationEnginePrivate::init() { Q_Q(QQmlApplicationEngine); - q->connect(&statusMapper, SIGNAL(mapped(QObject*)), - q, SLOT(_q_finishLoad(QObject*))); q->connect(q, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); q->connect(q, &QQmlApplicationEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit); #if QT_CONFIG(translation) @@ -113,20 +111,15 @@ void QQmlApplicationEnginePrivate::startLoad(const QUrl &url, const QByteArray & c->loadUrl(url); if (!c->isLoading()) { - _q_finishLoad(c); + finishLoad(c); return; } - statusMapper.setMapping(c, c); - q->connect(c, SIGNAL(statusChanged(QQmlComponent::Status)), - &statusMapper, SLOT(map())); + QObject::connect(c, &QQmlComponent::statusChanged, q, [this, c] { this->finishLoad(c); }); } -void QQmlApplicationEnginePrivate::_q_finishLoad(QObject *o) +void QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *c) { Q_Q(QQmlApplicationEngine); - QQmlComponent *c = qobject_cast<QQmlComponent *>(o); - if (!c) - return; switch (c->status()) { case QQmlComponent::Error: qWarning() << "QQmlApplicationEngine failed to load component"; diff --git a/src/qml/qml/qqmlapplicationengine.h b/src/qml/qml/qqmlapplicationengine.h index e64d7495cd..6c57f46c72 100644 --- a/src/qml/qml/qqmlapplicationengine.h +++ b/src/qml/qml/qqmlapplicationengine.h @@ -74,7 +74,6 @@ Q_SIGNALS: private: Q_DISABLE_COPY(QQmlApplicationEngine) Q_DECLARE_PRIVATE(QQmlApplicationEngine) - Q_PRIVATE_SLOT(d_func(), void _q_finishLoad(QObject*)) }; QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlapplicationengine_p.h b/src/qml/qml/qqmlapplicationengine_p.h index 8c342a43a9..4795170bed 100644 --- a/src/qml/qml/qqmlapplicationengine_p.h +++ b/src/qml/qml/qqmlapplicationengine_p.h @@ -42,7 +42,6 @@ #include "qqmlapplicationengine.h" #include "qqmlengine_p.h" -#include <QSignalMapper> #include <QCoreApplication> #include <QFileInfo> #include <QLibraryInfo> @@ -73,9 +72,8 @@ public: void startLoad(const QUrl &url, const QByteArray &data = QByteArray(), bool dataFlag = false); void loadTranslations(const QUrl &rootFile); - void _q_finishLoad(QObject *component); + void finishLoad(QQmlComponent *component); QList<QObject *> objects; - QSignalMapper statusMapper; QObject *appObj; #if QT_CONFIG(translation) diff --git a/src/quick/items/qquickopenglshadereffect_p.h b/src/quick/items/qquickopenglshadereffect_p.h index 64e79a9343..bc2e2975ee 100644 --- a/src/quick/items/qquickopenglshadereffect_p.h +++ b/src/quick/items/qquickopenglshadereffect_p.h @@ -70,7 +70,6 @@ QT_REQUIRE_CONFIG(quick_shadereffect); QT_BEGIN_NAMESPACE class QSGContext; -class QSignalMapper; class QFileSelector; class QQuickOpenGLCustomMaterialShader; |