From c34ab3714a4acbdff0daf6a58b9c8abcc4027ce1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 Jan 2016 01:34:30 +0100 Subject: 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 Reviewed-by: Laszlo Agocs Reviewed-by: Lars Knoll --- src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp | 17 ++--------------- src/plugins/platforms/eglfs/qeglfsdeviceintegration.h | 4 ++++ 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp index d64cc457f3..963c1604fc 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(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(directLoader(), key); } if (!integration) - integration = loadIntegration(loader(), key); + integration = qLoadPlugin(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 5ec98b37d1..ba47b3693e 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 -- cgit v1.2.3