diff options
author | Marc Mutz <[email protected]> | 2016-01-05 01:34:30 +0100 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2016-01-05 17:37:12 +0000 |
commit | c34ab3714a4acbdff0daf6a58b9c8abcc4027ce1 (patch) | |
tree | 4ffbae7e574aac07c542d56655bd068ddfcc8450 | |
parent | 9f74b840f9d61e3a1307058f45c5a145af83345e (diff) |
eglfs: use qLoadPlugin()
... instead of rolling your own.
qLoadPlugin() expects the create() method of the Plugin
class to take at least the QString key. Since this plugin
create() method doesn't take one, supply a wrapper.
Change-Id: I5b90b4b87e83f2e8a2e8942b792bb39b87d5f2de
Reviewed-by: Friedemann Kleint <[email protected]>
Reviewed-by: Laszlo Agocs <[email protected]>
Reviewed-by: Lars Knoll <[email protected]>
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp | 17 | ||||
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfsdeviceintegration.h | 4 |
2 files changed, 6 insertions, 15 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp index d64cc457f3e..963c1604fc6 100644 --- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp @@ -65,19 +65,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -static inline QEGLDeviceIntegration *loadIntegration(QFactoryLoader *loader, const QString &key) -{ - const int index = loader->indexOf(key); - if (index != -1) { - QObject *plugin = loader->instance(index); - if (QEGLDeviceIntegrationPlugin *factory = qobject_cast<QEGLDeviceIntegrationPlugin *>(plugin)) { - if (QEGLDeviceIntegration *result = factory->create()) - return result; - } - } - return Q_NULLPTR; -} - #endif // QT_NO_LIBRARY QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath) @@ -111,10 +98,10 @@ QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key, #ifndef QT_NO_LIBRARY if (!pluginPath.isEmpty()) { QCoreApplication::addLibraryPath(pluginPath); - integration = loadIntegration(directLoader(), key); + integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(directLoader(), key); } if (!integration) - integration = loadIntegration(loader(), key); + integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(loader(), key); if (integration) qCDebug(qLcEglDevDebug) << "Using EGL device integration" << key; else diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h index 5ec98b37d13..ba47b3693ee 100644 --- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h +++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h @@ -108,6 +108,10 @@ class Q_EGLFS_EXPORT QEGLDeviceIntegrationPlugin : public QObject public: virtual QEGLDeviceIntegration *create() = 0; + + // the pattern expected by qLoadPlugin calls for a QString argument. + // we don't need it, so don't bother subclasses with it: + QEGLDeviceIntegration *create(const QString &) { return create(); } }; class Q_EGLFS_EXPORT QEGLDeviceIntegrationFactory |