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 /src/qml/qml/qqmlapplicationengine.cpp | |
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>
Diffstat (limited to 'src/qml/qml/qqmlapplicationengine.cpp')
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
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"; |