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 <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
Marc Mutz 2016-01-05 01:34:30 +01:00
parent 9f74b840f9
commit c34ab3714a
2 changed files with 6 additions and 15 deletions

View File

@ -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

View File

@ -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